X-Git-Url: https://git.kernel.dk/?a=blobdiff_plain;f=init.c;h=63f2168eabcbbebb8cf6c2ae96967b46f2114713;hb=ad3e7e97780c406fca5afa56239b2a6b71cf6277;hp=e6378715b2fe4d42b882da45bc0c43ac44dcba66;hpb=2401022342f650ac7d845a14c7b9bf1cd87cead6;p=fio.git diff --git a/init.c b/init.c index e6378715..63f2168e 100644 --- a/init.c +++ b/init.c @@ -1217,7 +1217,7 @@ static void init_flags(struct thread_data *td) static int setup_random_seeds(struct thread_data *td) { - unsigned long seed; + uint64_t seed; unsigned int i; if (!td->o.rand_repeatable && !fio_option_is_set(&td->o, rand_seed)) { @@ -1273,8 +1273,7 @@ static char *make_filename(char *buf, size_t buf_size,struct thread_options *o, for (f = &fpre_keywords[0]; f->keyword; f++) f->strlen = strlen(f->keyword); - buf[buf_size - 1] = '\0'; - strncpy(buf, o->filename_format, buf_size - 1); + snprintf(buf, buf_size, "%s", o->filename_format); memset(copy, 0, sizeof(copy)); for (f = &fpre_keywords[0]; f->keyword; f++) { @@ -1353,7 +1352,7 @@ static char *make_filename(char *buf, size_t buf_size,struct thread_options *o, if (post_start) strncpy(dst, buf + post_start, dst_left); - strncpy(buf, copy, buf_size - 1); + snprintf(buf, buf_size, "%s", copy); } while (1); } @@ -1438,7 +1437,7 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num, int recursed, int client_type) { unsigned int i; - char fname[PATH_MAX]; + char fname[PATH_MAX + 1]; int numjobs, file_alloced; struct thread_options *o = &td->o; char logname[PATH_MAX + 32]; @@ -1887,7 +1886,7 @@ static int __parse_jobs_ini(struct thread_data *td, } } - string = malloc(4096); + string = malloc(OPT_LEN_MAX); /* * it's really 256 + small bit, 280 should suffice @@ -1920,7 +1919,7 @@ static int __parse_jobs_ini(struct thread_data *td, if (is_buf) p = strsep(&file, "\n"); else - p = fgets(string, 4096, f); + p = fgets(string, OPT_LEN_MAX, f); if (!p) break; } @@ -1989,7 +1988,7 @@ static int __parse_jobs_ini(struct thread_data *td, if (is_buf) p = strsep(&file, "\n"); else - p = fgets(string, 4096, f); + p = fgets(string, OPT_LEN_MAX, f); if (!p) break; dprint(FD_PARSE, "%s", p); @@ -2029,19 +2028,12 @@ static int __parse_jobs_ini(struct thread_data *td, */ if (access(filename, F_OK) && (ts = strrchr(file, '/'))) { - int len = ts - file + - strlen(filename) + 2; - - if (!(full_fn = calloc(1, len))) { + if (asprintf(&full_fn, "%.*s%s", + (int)(ts - file + 1), file, + filename) < 0) { ret = ENOMEM; break; } - - strncpy(full_fn, - file, (ts - file) + 1); - strncpy(full_fn + (ts - file) + 1, - filename, strlen(filename)); - full_fn[len - 1] = 0; filename = full_fn; }