mirror of
https://github.com/apache/nuttx.git
synced 2025-01-13 13:18:50 +08:00
sys/socket/scm: return NULL when cmsg_len is zero
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
This commit is contained in:
parent
d5f729ed25
commit
5d643b3bef
1 changed files with 5 additions and 4 deletions
|
@ -348,11 +348,12 @@ static inline FAR struct cmsghdr *__cmsg_nxthdr(FAR void *__ctl,
|
|||
unsigned int __size,
|
||||
FAR struct cmsghdr *__cmsg)
|
||||
{
|
||||
FAR struct cmsghdr *__ptr;
|
||||
size_t len = CMSG_ALIGN(__cmsg->cmsg_len);
|
||||
FAR struct cmsghdr *__ptr =
|
||||
(FAR struct cmsghdr *)(((FAR char *)__cmsg) + len);
|
||||
|
||||
__ptr = (FAR struct cmsghdr *)
|
||||
(((FAR char *)__cmsg) + CMSG_ALIGN(__cmsg->cmsg_len));
|
||||
if ((unsigned long)((FAR char *)(__ptr + 1) - (FAR char *)__ctl) > __size)
|
||||
if (len < sizeof(*__cmsg) ||
|
||||
(unsigned long)((FAR char *)(__ptr + 1) - (FAR char *)__ctl) > __size)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue