From d9644df9f41ce6d16c50298dff04ede5ce110b63 Mon Sep 17 00:00:00 2001 From: Ben England Date: Thu, 8 Sep 2016 14:54:06 -0400 Subject: [PATCH] safety first! --- client.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/client.c b/client.c index 410ffb89..82db5020 100644 --- a/client.c +++ b/client.c @@ -1302,12 +1302,15 @@ static int fio_client_handle_iolog(struct fio_client *client, return 1; } - /* generate a unique pathname for the log file using hostname */ - log_pathname = malloc(PATH_MAX+10); + /* allocate buffer big enough for next sprintf() call */ + log_pathname = malloc( 10 + + strlen((char * )pdu->name) + + strlen(client->hostname)); if (!log_pathname) { log_err("fio: memory allocation of unique pathname failed"); return -1; } + /* generate a unique pathname for the log file using hostname */ sprintf(log_pathname, "%s.%s", pdu->name, client->hostname); if (store_direct) { -- 2.25.1