projects
/
fio.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
net engine: fix potential buffer overrun in socket path
[fio.git]
/
engines
/
net.c
diff --git
a/engines/net.c
b/engines/net.c
index 110e158f114cbe210656476ff81af305d7d80248..3e26131be9a9913b853080b8ab85695aff60fb98 100644
(file)
--- 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;
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;
}
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;
memset(addr, 0, sizeof(*addr));
addr->sun_family = AF_UNIX;
- str
cpy(addr->sun_path, path
);
+ str
ncpy(addr->sun_path, path, sizeof(addr->sun_path) - 1
);
unlink(path);
len = sizeof(addr->sun_family) + strlen(path) + 1;
unlink(path);
len = sizeof(addr->sun_family) + strlen(path) + 1;
@@
-1092,6
+1093,7
@@
static int fio_netio_setup_listen_inet(struct thread_data *td, short port)
}
if (bind(fd, saddr, len) < 0) {
}
if (bind(fd, saddr, len) < 0) {
+ close(fd);
td_verror(td, errno, "bind");
return 1;
}
td_verror(td, errno, "bind");
return 1;
}
@@
-1196,6
+1198,7
@@
static int fio_netio_setup(struct thread_data *td)
if (!td->files_index) {
add_file(td, td->o.filename ?: "net", 0, 0);
td->o.nr_files = td->o.nr_files ?: 1;
if (!td->files_index) {
add_file(td, td->o.filename ?: "net", 0, 0);
td->o.nr_files = td->o.nr_files ?: 1;
+ td->o.open_files++;
}
if (!td->io_ops->data) {
}
if (!td->io_ops->data) {