prevent NULL reference from being used as '%s' argument.
authorSwen Schillig <swen@linux.ibm.com>
Wed, 22 Jan 2020 10:28:28 +0000 (11:28 +0100)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 28 Feb 2020 03:08:46 +0000 (03:08 +0000)
The two string arguments to torture_comment() can be NULL
as the succeeding checks suggest. This is not wanted because a compile
with --enable-developer throws an error of [-Werror=format-overflow=]
in those situations.

Signed-off-by: Swen Schillig <swen@linux.ibm.com>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source4/torture/rpc/drsuapi_cracknames.c

index 7d8139f8c1d5b520c5342c50a7b1a350a5c4ab88..a0daa60874841b866c46a537141ed85b7aeaca7d 100644 (file)
@@ -201,8 +201,11 @@ static bool test_DsCrackNamesMatrix(struct torture_context *tctx,
                for (j = 0; j < ARRAY_SIZE(formats); j++) {
                        torture_comment(tctx, "Converting %s (format %d)"
                                                " to %d gave %s\n",
-                                               n_from[i], formats[i],
-                                               formats[j], n_matrix[i][j]);
+                                       n_from[i] == NULL ? "NULL" : n_from[i],
+                                       formats[i], formats[j],
+                                       n_matrix[i][j] == NULL ?
+                                               "NULL" : n_matrix[i][j]);
+
                        if (n_matrix[i][j] == n_from[j]) {
                                
                        /* We don't have a from name for these yet (and we can't map to them to find it out) */