[SCM] Samba Shared Repository - branch master updated

Andreas Schneider asn at samba.org
Tue Feb 20 20:47:02 UTC 2018


The branch, master has been updated
       via  a6eac8f smbspool: Improve URI handling code
      from  7573b2a tests: Add tests for parsing LDAPv3 and LDAPv2 filter strings

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit a6eac8f64989235e7a297c14e349d98a3fc70e47
Author: Andreas Schneider <asn at samba.org>
Date:   Fri Jan 5 10:50:57 2018 +0100

    smbspool: Improve URI handling code
    
    This also checks that the URI given via the environment variables
    starts with smb://
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Alexander Bokovoy <ab at samba.org>
    Reviewed-by: David Disseldorp <ddiss at samba.org>
    
    Autobuild-User(master): Andreas Schneider <asn at cryptomilk.org>
    Autobuild-Date(master): Tue Feb 20 21:46:38 CET 2018 on sn-devel-144

-----------------------------------------------------------------------

Summary of changes:
 source3/client/smbspool.c | 29 ++++++++++++++++++-----------
 1 file changed, 18 insertions(+), 11 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/client/smbspool.c b/source3/client/smbspool.c
index 949cdb4..152492e 100644
--- a/source3/client/smbspool.c
+++ b/source3/client/smbspool.c
@@ -100,6 +100,8 @@ main(int argc,			/* I - Number of command-line arguments */
 	const char     *dev_uri;
 	const char     *config_file = NULL;
 	TALLOC_CTX     *frame = talloc_stackframe();
+	int cmp;
+	int len;
 
 	if (argc == 1) {
 		/*
@@ -153,20 +155,25 @@ main(int argc,			/* I - Number of command-line arguments */
 	}
 
 	/*
-         * Find the URI...
-         */
-
+	 * Find the URI ...
+	 */
 	dev_uri = getenv("DEVICE_URI");
-	if (dev_uri) {
-		strncpy(uri, dev_uri, sizeof(uri) - 1);
-	} else if (strncmp(argv[1], "smb://", 6) == 0) {
-		strncpy(uri, argv[1], sizeof(uri) - 1);
-	} else {
-		fputs("ERROR: No device URI found in DEVICE_URI environment variable or arg1 !\n", stderr);
-		goto done;
+	if (dev_uri == NULL || strlen(dev_uri) == 0) {
+		dev_uri = argv[1];
 	}
 
-	uri[sizeof(uri) - 1] = '\0';
+	cmp = strncmp(dev_uri, "smb://", 6);
+	if (cmp != 0) {
+		fprintf(stderr,
+			"ERROR: No valid device URI has been specified\n");
+		goto done;
+	}
+	len = snprintf(uri, sizeof(uri), "%s", dev_uri);
+	if (len >= sizeof(uri)) {
+		fprintf(stderr,
+			"ERROR: The URI is too long.\n");
+		goto done;
+	}
 
 	/*
          * Extract the destination from the URI...


-- 
Samba Shared Repository



More information about the samba-cvs mailing list