File: format-security

package info (click to toggle)
ippl 1.4.14-13
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 648 kB
  • sloc: ansic: 1,681; yacc: 443; sh: 319; lex: 163; makefile: 92
file content (25 lines) | stat: -rw-r--r-- 867 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
Description: Use proper format strings in snprintf
Author: gregor herrmann <gregoa@debian.org>
Bug: #643409
Forwarded: no
Last-Update: 2021-12-23
--- a/Source/log.c
+++ b/Source/log.c
@@ -147,7 +147,7 @@ void log_entry(int fd, char *entry) {
   }
 
   if (repeats > 0) {
-    snprintf(date, 27, asctime(localtime(&last_repeat)));
+    snprintf(date, 27, "%s", asctime(localtime(&last_repeat)));
     snprintf(repeat_message, 40, "last message repeated %d time(s)\n", repeats);
     write(fd, date+4, strlen(date)-10);
     write(fd, " ", 1);
@@ -155,7 +155,7 @@ void log_entry(int fd, char *entry) {
     repeats = 0;
   }
 
-  snprintf(date, 27, asctime(localtime(&current)));
+  snprintf(date, 27, "%s", asctime(localtime(&current)));
   write(fd, date+4, strlen(date)-10);
   write(fd, " ", 1);
   write(fd, entry, (strlen(entry) < 1023) ? strlen(entry) : 1023 );