From 798228cb7226e33798d26b414157c41be46563e8 Mon Sep 17 00:00:00 2001 From: Dmitry Frolov Date: Tue, 28 Aug 2007 06:16:14 +0000 Subject: [PATCH] Correct the misplaced recv in ipmi_lan_recv_packet() in lan and lanplus interfaces. Patch is submitted by Ferenc Wagner (wferi at niif dot hu). Quoting his email: "The rationale is that the following code expects to use the return value of recv (ie. a byte count) not that of select (the number of file descriptors). recv should be executed anyway, that's the whole point of this snippet..." The original patch is for lan interface but it also applies to lanplus. --- ipmitool/src/plugins/lan/lan.c | 12 +++++------- ipmitool/src/plugins/lanplus/lanplus.c | 12 +++++------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/ipmitool/src/plugins/lan/lan.c b/ipmitool/src/plugins/lan/lan.c index 37f2b02..6fc9730 100644 --- a/ipmitool/src/plugins/lan/lan.c +++ b/ipmitool/src/plugins/lan/lan.c @@ -265,14 +265,12 @@ ipmi_lan_recv_packet(struct ipmi_intf * intf) tmout.tv_usec = 0; ret = select(intf->fd + 1, &read_set, NULL, &err_set, &tmout); - if (ret < 0) { - if (FD_ISSET(intf->fd, &err_set) || !FD_ISSET(intf->fd, &read_set)) - return NULL; + if (ret < 0 || FD_ISSET(intf->fd, &err_set) || !FD_ISSET(intf->fd, &read_set)) + return NULL; - ret = recv(intf->fd, &rsp.data, IPMI_BUF_SIZE, 0); - if (ret < 0) - return NULL; - } + ret = recv(intf->fd, &rsp.data, IPMI_BUF_SIZE, 0); + if (ret < 0) + return NULL; } if (ret == 0) diff --git a/ipmitool/src/plugins/lanplus/lanplus.c b/ipmitool/src/plugins/lanplus/lanplus.c index 86f35e6..1890802 100644 --- a/ipmitool/src/plugins/lanplus/lanplus.c +++ b/ipmitool/src/plugins/lanplus/lanplus.c @@ -425,14 +425,12 @@ ipmi_lan_recv_packet(struct ipmi_intf * intf) tmout.tv_usec = 0; ret = select(intf->fd + 1, &read_set, NULL, &err_set, &tmout); - if (ret < 0) { - if (FD_ISSET(intf->fd, &err_set) || !FD_ISSET(intf->fd, &read_set)) - return NULL; + if (ret < 0 || FD_ISSET(intf->fd, &err_set) || !FD_ISSET(intf->fd, &read_set)) + return NULL; - ret = recv(intf->fd, &rsp.data, IPMI_BUF_SIZE, 0); - if (ret < 0) - return NULL; - } + ret = recv(intf->fd, &rsp.data, IPMI_BUF_SIZE, 0); + if (ret < 0) + return NULL; } if (ret == 0)