From: Jevon Qiao Date: Thu, 28 Jul 2016 07:22:40 +0000 (+0800) Subject: Fix segmentation fault while specifying clustername with rbd engine X-Git-Tag: fio-2.14~77 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=89e5ec960081f40b19017c21906ca9be139f9dea Fix segmentation fault while specifying clustername with rbd engine Fio with rbd engine will panic if clustername option is specified but clientname is not. In that case, o->client_name will be a NULL pointer, strlen(o->client_name) in _fio_rbd_connect() will lead to the segmentation fault. Signed-off-by: Jevon Qiao --- diff --git a/engines/rbd.c b/engines/rbd.c index 7a109eed..c5abd2d2 100644 --- a/engines/rbd.c +++ b/engines/rbd.c @@ -131,15 +131,18 @@ static int _fio_rbd_connect(struct thread_data *td) char *client_name = NULL; /* - * If we specify cluser name, the rados_creat2 + * If we specify cluser name, the rados_create2 * will not assume 'client.'. name is considered * as a full type.id namestr */ - if (!index(o->client_name, '.')) { - client_name = calloc(1, strlen("client.") + - strlen(o->client_name) + 1); - strcat(client_name, "client."); - o->client_name = strcat(client_name, o->client_name); + if (o->client_name) { + if (!index(o->client_name, '.')) { + client_name = calloc(1, strlen("client.") + + strlen(o->client_name) + 1); + strcat(client_name, "client."); + o->client_name = strcat(client_name, + o->client_name); + } } r = rados_create2(&rbd->cluster, o->cluster_name, o->client_name, 0);