From: Jens Axboe Date: Sat, 1 Oct 2011 04:20:37 +0000 (-0600) Subject: Use length guarded sprintf functions X-Git-Tag: fio-1.99~83 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=a781480e959e4cad32f27915bdb5dab948aa1c6e;ds=sidebyside Use length guarded sprintf functions Signed-off-by: Jens Axboe --- diff --git a/infolog.c b/infolog.c index 8396522e..b7b4a5e9 100644 --- a/infolog.c +++ b/infolog.c @@ -12,7 +12,7 @@ int log_info(const char *format, ...) size_t len; va_start(args, format); - len = vsprintf(buffer, format, args); + len = vsnprintf(buffer, sizeof(buffer), format, args); va_end(args); if (is_backend) @@ -28,7 +28,7 @@ int log_err(const char *format, ...) size_t len; va_start(args, format); - len = vsprintf(buffer, format, args); + len = vsnprintf(buffer, sizeof(buffer), format, args); va_end(args); if (is_backend) diff --git a/server.c b/server.c index 4a78f383..a70dc14f 100644 --- a/server.c +++ b/server.c @@ -143,7 +143,6 @@ struct fio_net_cmd *fio_net_cmd_read(int sk) return NULL; } - return ret; } @@ -392,7 +391,7 @@ int fio_server_log(const char *format, ...) va_list args; va_start(args, format); - sprintf(buffer, format, args); + snprintf(buffer, sizeof(buffer), format, args); va_end(args); return fio_server_text_output(buffer, strlen(buffer));