projects
/
tinc
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Check that UNIX socket filenames are not too long.
[tinc]
/
src
/
tincctl.c
diff --git
a/src/tincctl.c
b/src/tincctl.c
index
bfc16af
..
8b49c44
100644
(file)
--- a/
src/tincctl.c
+++ b/
src/tincctl.c
@@
-853,14
+853,17
@@
bool connect_tincd(bool verbose) {
return false;
}
return false;
}
- struct sockaddr_un sa;
+ struct sockaddr_un sa = {
+ .sun_family = AF_UNIX,
+ };
- sa.sun_family = AF_UNIX;
+ if(strlen(unixsocketname) >= sizeof(sa.sun_path)) {
+ fprintf(stderr, "UNIX socket filename %s is too long!", unixsocketname);
+ return false;
+ }
strncpy(sa.sun_path, unixsocketname, sizeof(sa.sun_path));
strncpy(sa.sun_path, unixsocketname, sizeof(sa.sun_path));
- sa.sun_path[sizeof(sa.sun_path) - 1] = 0;
-
fd = socket(AF_UNIX, SOCK_STREAM, 0);
if(fd < 0) {
fd = socket(AF_UNIX, SOCK_STREAM, 0);
if(fd < 0) {