From: Jens Axboe Date: Fri, 11 Apr 2014 17:34:17 +0000 (-0600) Subject: Ensure that fread() string is always NULL terminated X-Git-Tag: fio-2.1.9~70 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=e0c8b741108cd59ce4435082b5afd5c69a6f713e Ensure that fread() string is always NULL terminated Signed-off-by: Jens Axboe --- diff --git a/backend.c b/backend.c index 5ac36592..b05e5437 100644 --- a/backend.c +++ b/backend.c @@ -1110,7 +1110,8 @@ static int switch_ioscheduler(struct thread_data *td) /* * Read back and check that the selected scheduler is now the default. */ - ret = fread(tmp, 1, sizeof(tmp), f); + memset(tmp, 0, sizeof(tmp)); + ret = fread(tmp, 1, sizeof(tmp) - 1, f); if (ferror(f) || ret < 0) { td_verror(td, errno, "fread"); fclose(f);