if the workgroup name is longer than 16 chars we get garbage in the string
authoridra <idra@0c0555d6-39d7-0310-84fc-f1cc0bd64818>
Thu, 8 Feb 2007 14:55:21 +0000 (14:55 +0000)
committeridra <idra@0c0555d6-39d7-0310-84fc-f1cc0bd64818>
Thu, 8 Feb 2007 14:55:21 +0000 (14:55 +0000)
server_len is usually 256 (fstring).

Correctly terminate saving the lenght

git-svn-id: svn+ssh://svn.samba.org/data/svn/samba/branches/SAMBA_3_0@21239 0c0555d6-39d7-0310-84fc-f1cc0bd64818

source/libsmb/libsmbclient.c

index 48f6c3a..b3c8731 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;
-               
        }
 
        /*