mirror of
https://github.com/NixOS/nix.git
synced 2025-11-13 05:56:03 +01:00
nix-find-roots: Properly fail if the socket filename is too long
Otherwise we get a buffer overflow, and bad things can happen
This commit is contained in:
parent
2d651ad2d0
commit
7299ad523b
1 changed files with 2 additions and 0 deletions
|
|
@ -124,6 +124,8 @@ int main(int argc, char * * argv)
|
|||
chdir(socketDir.c_str());
|
||||
|
||||
fs::remove(socketFilename);
|
||||
if (socketFilename.string().size() + 1 >= sizeof(addr.sun_path))
|
||||
throw Error("socket path '" + socketFilename.string() + "' is too long");
|
||||
strcpy(addr.sun_path, socketFilename.c_str());
|
||||
if (bind(mySock, (struct sockaddr*) &addr, sizeof(addr)) == -1) {
|
||||
throw Error("Cannot bind to socket");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue