From: Jens Axboe Date: Mon, 30 Oct 2006 12:32:08 +0000 (+0100) Subject: [PATCH] Potential overflow and unused variable X-Git-Tag: fio-1.8~22 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=fee3bb48f748afe5cf10f8505e1efd36b87c627e;hp=16b462aeb47996111ee6aa516c9226708db7c248;ds=sidebyside [PATCH] Potential overflow and unused variable 'tmpbuf' was unused. Limit [name] entry to 255 chars to avoid overflowing the buffer. Signed-off-by: Jens Axboe --- diff --git a/init.c b/init.c index 2cfa6d28..732cceb9 100644 --- a/init.c +++ b/init.c @@ -843,7 +843,7 @@ int parse_jobs_ini(char *file, int stonewall_flag) { unsigned int global; struct thread_data *td; - char *string, *name, *tmpbuf; + char *string, *name; fpos_t off; FILE *f; char *p; @@ -857,7 +857,7 @@ int parse_jobs_ini(char *file, int stonewall_flag) string = malloc(4096); name = malloc(256); - tmpbuf = malloc(4096); + memset(name, 0, 256); stonewall = stonewall_flag; while ((p = fgets(string, 4096, f)) != NULL) { @@ -865,7 +865,7 @@ int parse_jobs_ini(char *file, int stonewall_flag) break; if (is_empty_or_comment(p)) continue; - if (sscanf(p, "[%s]", name) != 1) + if (sscanf(p, "[%255s]", name) != 1) continue; global = !strncmp(name, "global", 6); @@ -916,7 +916,6 @@ int parse_jobs_ini(char *file, int stonewall_flag) free(string); free(name); - free(tmpbuf); fclose(f); return ret; }