X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=server.c;h=9442764ed609a4d52ea472ef844a93f8f7dcbb45;hp=beee2db19d2a346b9184b5a88393f5e520a80ec6;hb=afdcad2315c22200d594a29885053d7671881ebb;hpb=12d02717a293cdd0c85504c958f7bf57411bb30b diff --git a/server.c b/server.c index beee2db1..9442764e 100644 --- a/server.c +++ b/server.c @@ -1095,18 +1095,19 @@ static void convert_dus(struct disk_util_stat *dst, struct disk_util_stat *src) { int i; - strcpy((char *) dst->name, (char *) src->name); + dst->name[FIO_DU_NAME_SZ - 1] = '\0'; + strncpy((char *) dst->name, (char *) src->name, FIO_DU_NAME_SZ - 1); for (i = 0; i < 2; i++) { - dst->ios[i] = cpu_to_le32(src->ios[i]); - dst->merges[i] = cpu_to_le32(src->merges[i]); - dst->sectors[i] = cpu_to_le64(src->sectors[i]); - dst->ticks[i] = cpu_to_le32(src->ticks[i]); + dst->s.ios[i] = cpu_to_le32(src->s.ios[i]); + dst->s.merges[i] = cpu_to_le32(src->s.merges[i]); + dst->s.sectors[i] = cpu_to_le64(src->s.sectors[i]); + dst->s.ticks[i] = cpu_to_le32(src->s.ticks[i]); } - dst->io_ticks = cpu_to_le32(src->io_ticks); - dst->time_in_queue = cpu_to_le32(src->time_in_queue); - dst->msec = cpu_to_le64(src->msec); + dst->s.io_ticks = cpu_to_le32(src->s.io_ticks); + dst->s.time_in_queue = cpu_to_le32(src->s.time_in_queue); + dst->s.msec = cpu_to_le64(src->s.msec); } void fio_server_send_du(void) @@ -1367,6 +1368,8 @@ static int fio_init_server_connection(void) if (sk < 0) return sk; + memset(bind_str, 0, sizeof(bind_str)); + if (!bind_sock) { char *p, port[16]; const void *src; @@ -1386,9 +1389,9 @@ static int fio_init_server_connection(void) if (p) strcat(p, port); else - strcpy(bind_str, port); + strncpy(bind_str, port, sizeof(bind_str) - 1); } else - strcpy(bind_str, bind_sock); + strncpy(bind_str, bind_sock, sizeof(bind_str) - 1); log_info("fio: server listening on %s\n", bind_str); @@ -1683,6 +1686,7 @@ int fio_start_server(char *pidfile) if (check_existing_pidfile(pidfile)) { log_err("fio: pidfile %s exists and server appears alive\n", pidfile); + free(pidfile); return -1; } @@ -1694,6 +1698,7 @@ int fio_start_server(char *pidfile) } else if (pid) { int ret = write_pid(pid, pidfile); + free(pidfile); exit(ret); }