s4:torture: Use strlcpy() in gen_name()
authorAndreas Schneider <asn@samba.org>
Wed, 9 May 2018 15:35:45 +0000 (17:35 +0200)
committerAndreas Schneider <asn@cryptomilk.org>
Thu, 17 May 2018 15:30:09 +0000 (17:30 +0200)
../source4/torture/basic/mangle_test.c: In function ‘gen_name’:
../source4/torture/basic/mangle_test.c:148:3: error: ‘strncpy’ output
    truncated before terminating nul copying 5 bytes from a string of the
    same length [-Werror=stringop-truncation]
   strncpy(p, "ABCDE", 5);
   ^~~~~~~~~~~~~~~~~~~~~~

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13437

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
source4/torture/basic/mangle_test.c

index 0b7d696e67732352cb458407b4cf7d95801102b1..df12b3ce821cad80669cf6b4aa8a209d63e27ff6 100644 (file)
@@ -145,7 +145,7 @@ static char *gen_name(TALLOC_CTX *mem_ctx)
 
        /* and a medium probability of a common lead string */
        if ((len > 5) && (random() % 10 == 0)) {
-               strncpy(p, "ABCDE", 5);
+               strlcpy(p, "ABCDE", 6);
        }
 
        /* and a high probability of a good extension length */