unix-server: guard against buffer overflow
sun_path is fairly small, and while the input is a smaller constant, you never know how that might change.
This commit is contained in:
parent
21154a3e6b
commit
77d34c3096
@ -44,7 +44,8 @@ int get_server_socket(char *socket_address)
|
||||
}
|
||||
memset(&sockname, 0, sizeof(sockname));
|
||||
sockname.sun_family = AF_UNIX;
|
||||
memcpy(sockname.sun_path, socket_address, strlen(socket_address));
|
||||
strncpy(sockname.sun_path, socket_address, sizeof sockname.sun_path);
|
||||
sockname.sun_path[sizeof sockname.sun_path - 1] = 0;
|
||||
|
||||
if (bind(s, (struct sockaddr *) &sockname, sizeof(sockname)) == -1) {
|
||||
printf("bind() failed\n");
|
||||
|
Loading…
Reference in New Issue
Block a user