r21239: if the workgroup name is longer than 16 chars we get garbage in the string
authorSimo Sorce <idra@samba.org>
Thu, 8 Feb 2007 14:55:21 +0000 (14:55 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 17:17:50 +0000 (12:17 -0500)
server_len is usually 256 (fstring).

Correctly terminate saving the lenght
(This used to be commit e7e44554bf7c61020e2c5c652e3f8f37a296d3aa)

source3/libsmb/libsmbclient.c

index 48f6c3a9c244e3f5bdabdd8bc4abbf8ce29ca282..b3c873145fea56abd8b6a54c4ce427c79329f9e3 100644 (file)
@@ -339,14 +339,15 @@ smbc_parse_path(SMBCCTX *context,
            goto decoding;
 
        if (*p == '/') {
+               int wl = strlen(context->workgroup);
 
-               strncpy(server, context->workgroup, 
-                       ((strlen(context->workgroup) < 16)
-                         ? strlen(context->workgroup)
-                         : 16));
-                server[server_len - 1] = '\0';
+               if (wl > 16) {
+                       wl = 16;
+               }
+
+               strncpy(server, context->workgroup, wl);
+                server[wl] = '\0';
                return 0;
-               
        }
 
        /*