Skip to content

Commit 24675d7

Browse files
cgrulesengd: Fix the return value check in recvfrom
In cgre_receive_netlink_msg::recvfrom(), the return value recv_len is checked against ENOBUFS, which is an errno value that represents the last occurred error. However, this comparison has two issues: First, if the recv_len message bytes are equal to the value of ENOBUFS, it will return a false positive error. Second, recv_len is not checked for -1, which indicates an unexpected event that requires investigation. Fortunately, the next line acts as a safety net, returning on error conditions and EOF. Fix this by checking for -1 (error) and comparing errno against ENOBUFS. Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
1 parent 303e69c commit 24675d7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/daemon/cgrulesengd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ static int cgre_receive_netlink_msg(int sk_nl)
567567
from_nla_len = sizeof(from_nla);
568568
recv_len = recvfrom(sk_nl, buff, sizeof(buff), 0, (struct sockaddr *)&from_nla,
569569
&from_nla_len);
570-
if (recv_len == ENOBUFS) {
570+
if (recv_len == -1 && errno == ENOBUFS) {
571571
flog(LOG_ERR, "ERROR: NETLINK BUFFER FULL, MESSAGE DROPPED!\n");
572572
return 0;
573573
}

0 commit comments

Comments
 (0)