]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
logopenfile: fix minor format string warning
authorVictor Julien <vjulien@oisf.net>
Wed, 27 Apr 2022 09:39:27 +0000 (11:39 +0200)
committerVictor Julien <vjulien@oisf.net>
Tue, 3 May 2022 11:30:20 +0000 (13:30 +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.
(cherry picked from commit 07d0ae04d34cdf029729b474fb22598f154fcea6)

src/util-logopenfile.c

index 0899b8cf3b25296a4c3e5d933a46c438f78811ed..dfa2f30f098e7b7c27cb1ab05ffff87d470bd730 100644 (file)
@@ -738,7 +738,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\"; "
@@ -747,7 +747,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;
 }