Check for UNIX-doman socket name truncation
This commit is contained in:
parent
d5a6e978b9
commit
bdff59a5f6
1 changed files with 6 additions and 1 deletions
7
quark.c
7
quark.c
|
@ -841,6 +841,7 @@ static int
|
||||||
getusock(char *udsname)
|
getusock(char *udsname)
|
||||||
{
|
{
|
||||||
struct sockaddr_un addr;
|
struct sockaddr_un addr;
|
||||||
|
size_t udsnamelen;
|
||||||
int insock;
|
int insock;
|
||||||
|
|
||||||
if ((insock = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) {
|
if ((insock = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) {
|
||||||
|
@ -849,7 +850,11 @@ getusock(char *udsname)
|
||||||
|
|
||||||
memset(&addr, 0, sizeof(addr));
|
memset(&addr, 0, sizeof(addr));
|
||||||
addr.sun_family = AF_UNIX;
|
addr.sun_family = AF_UNIX;
|
||||||
strncpy(addr.sun_path, udsname, sizeof(addr.sun_path) - 1);
|
|
||||||
|
if ((udsnamelen = strlen(udsname)) > sizeof(addr.sun_path) - 1) {
|
||||||
|
die("%s: UNIX-domain socket name truncated\n", argv0);
|
||||||
|
}
|
||||||
|
memcpy(addr.sun_path, udsname, udsnamelen + 1);
|
||||||
|
|
||||||
unlink(udsname);
|
unlink(udsname);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue