Prevent buffer overflow with a long socket path name.
The code wasn't checking for overflow before copying the socket path name to to the sun_path field, which is usually much smaller than PATH_MAX. Report and initial patch by Paul Wilkinson.
This commit is contained in:
parent
fc78d94e7f
commit
a51207bf47
6
attach.c
6
attach.c
|
|
@ -52,6 +52,12 @@ connect_socket(char *name)
|
|||
int s;
|
||||
struct sockaddr_un sockun;
|
||||
|
||||
if (strlen(name) > sizeof(sockun.sun_path) - 1)
|
||||
{
|
||||
errno = ENAMETOOLONG;
|
||||
return -1;
|
||||
}
|
||||
|
||||
s = socket(PF_UNIX, SOCK_STREAM, 0);
|
||||
if (s < 0)
|
||||
return -1;
|
||||
|
|
|
|||
Loading…
Reference in New Issue