From: Jens Axboe Date: Mon, 14 Apr 2014 14:49:04 +0000 (-0600) Subject: net engine: fix potential buffer overrun in socket path X-Git-Tag: fio-2.1.9~58 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=4b159fa61a9c3ed7e00c8135189c184dcc48c69f net engine: fix potential buffer overrun in socket path Signed-off-by: Jens Axboe --- diff --git a/engines/net.c b/engines/net.c index d036a581..3e26131b 100644 --- a/engines/net.c +++ b/engines/net.c @@ -945,7 +945,8 @@ static int fio_netio_setup_connect_unix(struct thread_data *td, struct sockaddr_un *soun = &nd->addr_un; soun->sun_family = AF_UNIX; - strcpy(soun->sun_path, path); + memset(soun->sun_path, 0, sizeof(soun->sun_path)); + strncpy(soun->sun_path, path, sizeof(soun->sun_path) - 1); return 0; } @@ -976,7 +977,7 @@ static int fio_netio_setup_listen_unix(struct thread_data *td, const char *path) memset(addr, 0, sizeof(*addr)); addr->sun_family = AF_UNIX; - strcpy(addr->sun_path, path); + strncpy(addr->sun_path, path, sizeof(addr->sun_path) - 1); unlink(path); len = sizeof(addr->sun_family) + strlen(path) + 1;