mirror of
https://github.com/trapexit/mergerfs.git
synced 2026-10-26 19:01:56 -04:00
Add NULL check for cmsg in receive_fd to prevent segfault
This commit is contained in:
parent
b768ba8ce1
commit
cc67e791bf
1 changed files with 14 additions and 5 deletions
|
|
@ -259,11 +259,20 @@ static int receive_fd(int fd)
|
|||
}
|
||||
|
||||
cmsg = CMSG_FIRSTHDR(&msg);
|
||||
if (cmsg->cmsg_type != SCM_RIGHTS) {
|
||||
fprintf(stderr, "got control message of unknown type %d\n",
|
||||
cmsg->cmsg_type);
|
||||
return -1;
|
||||
}
|
||||
if(!cmsg)
|
||||
{
|
||||
fprintf(stderr,"no control message received or not enough buf space\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(cmsg->cmsg_type != SCM_RIGHTS)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"got control message of unknown type %d\n",
|
||||
cmsg->cmsg_type);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return *(int*)CMSG_DATA(cmsg);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue