Source: openvas-scanner
Followup-For: Bug #1067075
X-Debbugs-Cc: scho...@ubuntu.com
Control: tags -1 ftbfs

It seems I missed a few (and messed something when test building?),
new patch attached.


-- System Information:
Debian Release: trixie/sid
  APT prefers noble
  APT policy: (500, 'noble'), (100, 'noble-proposed')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 6.8.0-11-generic (SMP w/8 CPU threads; PREEMPT)
Kernel taint flags: TAINT_PROPRIETARY_MODULE, TAINT_USER, TAINT_OOT_MODULE
Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled
>From b75d19ecd90498e6d005c62b8fd4d31f3909a5cb Mon Sep 17 00:00:00 2001
From: Simon Chopin <simon.cho...@canonical.com>
Date: Fri, 22 Mar 2024 17:43:22 +0100
Subject: [PATCH] Fix printf specifiers for time_t-related types

Best to only use fixed-width types and explicit casting.
---
 src/attack.c       | 8 +++++---
 src/pluginlaunch.c | 8 +++++---
 2 files changed, 10 insertions(+), 6 deletions(-)

Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1067075
--- a/src/attack.c
+++ b/src/attack.c
@@ -44,9 +44,11 @@
 #include <gvm/util/nvticache.h> /* for nvticache_t */
 #include <pthread.h>
 #include <signal.h>
+#include <stdint.h>
 #include <string.h>   /* for strlen() */
 #include <sys/wait.h> /* for waitpid() */
 #include <unistd.h>   /* for close() */
+#include <inttypes.h>
 
 #define ERR_HOST_DEAD -1
 
@@ -987,9 +989,9 @@
           now.tv_usec += 1000000;
         }
       g_message (
-        "Vulnerability scan %s finished for host %s in %ld.%.2ld seconds",
-        globals->scan_id, ip_str, (long) (now.tv_sec - then.tv_sec),
-        (long) ((now.tv_usec - then.tv_usec) / 10000));
+        "Vulnerability scan %s finished for host %s in %"PRIu64".%.2"PRIu32" 
seconds",
+        globals->scan_id, ip_str, (uint64_t) (now.tv_sec - then.tv_sec),
+        (uint32_t) ((now.tv_usec - then.tv_usec) / 10000));
     }
 }
 
@@ -1614,13 +1616,13 @@
 
   gettimeofday (&now, NULL);
   if (test_alive_hosts_only)
-    g_message ("Vulnerability scan %s finished in %ld seconds: "
+    g_message ("Vulnerability scan %s finished in %"PRIu64" seconds: "
                "%d alive hosts of %d",
-               globals->scan_id, now.tv_sec - then.tv_sec,
+               globals->scan_id, (uint64_t)(now.tv_sec - then.tv_sec),
                gvm_hosts_count (alive_hosts_list), gvm_hosts_count (hosts));
   else
-    g_message ("Vulnerability scan %s finished in %ld seconds: %d hosts",
-               globals->scan_id, now.tv_sec - then.tv_sec,
+    g_message ("Vulnerability scan %s finished in %"PRIu64" seconds: %d hosts",
+               globals->scan_id, (uint64_t)(now.tv_sec - then.tv_sec),
                gvm_hosts_count (hosts));
 
   gvm_hosts_free (hosts);
--- a/src/pluginlaunch.c
+++ b/src/pluginlaunch.c
@@ -24,8 +24,10 @@
 #include "utils.h"
 
 #include <errno.h>          /* for errno() */
+#include <inttypes.h>
 #include <gvm/base/prefs.h> /* for prefs_get_bool() */
 #include <gvm/util/nvticache.h>
+#include <stdint.h>
 #include <stdio.h>  /* for perror() */
 #include <stdlib.h> /* for atoi() */
 #include <string.h>
@@ -187,10 +189,10 @@
                     {
                       char *name = nvticache_get_filename (oid);
                       g_message (
-                        "%s (%s) [%d] finished its job in %ld.%.3ld seconds",
+                        "%s (%s) [%d] finished its job in 
%"PRIu64".%.3"PRIu32" seconds",
                         name, oid, processes[i].pid,
-                        (long) (now.tv_sec - processes[i].start.tv_sec),
-                        (long) ((now.tv_usec - processes[i].start.tv_usec)
+                        (uint64_t) (now.tv_sec - processes[i].start.tv_sec),
+                        (uint32_t) ((now.tv_usec - processes[i].start.tv_usec)
                                 / 1000));
                       g_free (name);
                     }
--- a/nasl/nasl_misc_funcs.c
+++ b/nasl/nasl_misc_funcs.c
@@ -30,6 +30,7 @@
 #include <glib.h>
 #include <gvm/util/compressutils.h> /* for gvm_uncompress */
 #include <gvm/util/kb.h>            /* for KB_TYPE_STR */
+#include <inttypes.h>
 #include <stdbool.h>                /* for boolean */
 #include <stdlib.h>                 /* for lrand48 */
 #include <string.h>                 /* for bzero */
@@ -657,7 +658,7 @@
       nasl_perror (lexic, "gettimeofday: %s\n", strerror (errno));
       return NULL;
     }
-  sprintf (str, "%u.%06u", (unsigned int) t.tv_sec, (unsigned int) t.tv_usec);
+  sprintf (str, "%"PRIu64".%06"PRIu32, (uint64_t) t.tv_sec, (uint32_t) 
t.tv_usec);
   retc = alloc_typed_cell (CONST_DATA);
   retc->size = strlen (str);
   retc->x.str_val = g_malloc0 (retc->size);

Reply via email to