sock/posix: fix potential segfault in zero-copy
CMSG_FIRSTHDR could theoretically return NULL. Check it for the peace of mind. CMSG_FIRSTHDR() returns a pointer to the first cmsghdr in the ancillary data buffer associated with the passed msghdr. It returns NULL if there isn't enough space for a cmsghdr in the buffer. Change-Id: I6c7e1eb59121b59c568d3ad7f5eda649a49026f4 Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com> Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/771 Reviewed-by: Paul Luse <paul.e.luse@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
parent
71efe5db24
commit
8c37b10702
@ -495,7 +495,7 @@ _sock_check_zcopy(struct spdk_sock *sock)
|
||||
}
|
||||
|
||||
cm = CMSG_FIRSTHDR(&msgh);
|
||||
if (cm->cmsg_level != SOL_IP || cm->cmsg_type != IP_RECVERR) {
|
||||
if (!cm || cm->cmsg_level != SOL_IP || cm->cmsg_type != IP_RECVERR) {
|
||||
SPDK_WARNLOG("Unexpected cmsg level or type!\n");
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user