]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
logopenfile: fix minor format string warning 7322/head
authorVictor Julien <vjulien@oisf.net>
Wed, 27 Apr 2022 09:39:27 +0000 (11:39 +0200)
committerVictor Julien <vjulien@oisf.net>
Wed, 27 Apr 2022 10:21:49 +0000 (12:21 +0200)
cppcheck:

src/util-logopenfile.c:743:13: warning: %d in format string (no. 2) requires 'int' but the argument type is 'unsigned int'. [invalidPrintfArgType_sint]
            snprintf(threaded_name, len, "%s.%d.%s", tname, unique_id, ext);
            ^
src/util-logopenfile.c:752:9: warning: %d in format string (no. 2) requires 'int' but the argument type is 'unsigned int'. [invalidPrintfArgType_sint]
        snprintf(threaded_name, len, "%s.%d", original_name, unique_id);
        ^

Bug: #5291.

src/util-logopenfile.c

index 84c1bc2cc84f1184022feba85d6503fa015cd701..1150166d93d488519c438e93765eba23aa3c2bdd 100644 (file)
@@ -740,7 +740,7 @@ static bool LogFileThreadedName(
         tname[dotpos] = '\0';
         char *ext = tname + dotpos + 1;
         if (strlen(tname) && strlen(ext)) {
-            snprintf(threaded_name, len, "%s.%d.%s", tname, unique_id, ext);
+            snprintf(threaded_name, len, "%s.%u.%s", tname, unique_id, ext);
         } else {
             FatalError(SC_ERR_FATAL,
                     "Invalid filename for threaded mode \"%s\"; "
@@ -749,7 +749,7 @@ static bool LogFileThreadedName(
         }
         SCFree(tname);
     } else {
-        snprintf(threaded_name, len, "%s.%d", original_name, unique_id);
+        snprintf(threaded_name, len, "%s.%u", original_name, unique_id);
     }
     return true;
 }