X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=engines%2Fnet.c;h=137c5799169fa10fbdbaeb597c87f0c7c17f0b95;hp=df8b62597ef681392c76f25110d4dd9007b98870;hb=443662efa60d9082bc820641e7d1d31dd58d3ae1;hpb=a732c9f3333ae96822295fb4b50d39d38fe04243;ds=sidebyside diff --git a/engines/net.c b/engines/net.c index df8b6259..137c5799 100644 --- a/engines/net.c +++ b/engines/net.c @@ -353,7 +353,7 @@ static int fio_netio_setup_listen(struct thread_data *td, short port) static int fio_netio_init(struct thread_data *td) { struct netio_data *nd = td->io_ops->data; - unsigned short port; + unsigned int port; char host[64], buf[128]; char *sep; int ret; @@ -370,15 +370,18 @@ static int fio_netio_init(struct thread_data *td) strcpy(buf, td->o.filename); sep = strchr(buf, '/'); - if (!sep) { - log_err("fio: bad network host/port <<%s>>\n", td->o.filename); - return 1; - } + if (!sep) + goto bad_host; *sep = '\0'; sep++; strcpy(host, buf); - port = atoi(sep); + if (!strlen(host)) + goto bad_host; + + port = strtol(sep, NULL, 10); + if (!port || port > 65535) + goto bad_host; if (td_read(td)) { nd->send_to_net = 0; @@ -389,6 +392,9 @@ static int fio_netio_init(struct thread_data *td) } return ret; +bad_host: + log_err("fio: bad network host/port: %s\n", td->o.filename); + return 1; } static void fio_netio_cleanup(struct thread_data *td)