Commit 7f76c403751ab917b2ebed5663079a6b2956eebd

Authored by Scott Wiersdorf
Committed by Linus Torvalds
1 parent d1ab824be4

getdelays.c: fix overrun

A patch for getdelays.c that fixes a buffer overrun when you set -w.

Cc: <matt@bluehost.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Showing 1 changed file with 2 additions and 4 deletions Side-by-side Diff

Documentation/accounting/getdelays.c
... ... @@ -61,8 +61,6 @@
61 61 #define MAX_MSG_SIZE 1024
62 62 /* Maximum number of cpus expected to be specified in a cpumask */
63 63 #define MAX_CPUS 32
64   -/* Maximum length of pathname to log file */
65   -#define MAX_FILENAME 256
66 64  
67 65 struct msgtemplate {
68 66 struct nlmsghdr n;
... ... @@ -231,7 +229,7 @@
231 229 int count = 0;
232 230 int write_file = 0;
233 231 int maskset = 0;
234   - char logfile[128];
  232 + char *logfile = NULL;
235 233 int loop = 0;
236 234  
237 235 struct msgtemplate msg;
... ... @@ -251,7 +249,7 @@
251 249 print_io_accounting = 1;
252 250 break;
253 251 case 'w':
254   - strncpy(logfile, optarg, MAX_FILENAME);
  252 + logfile = strdup(optarg);
255 253 printf("write to file %s\n", logfile);
256 254 write_file = 1;
257 255 break;