When calling the multipathd CLI we're getting the message
error -1 receiving packet
instead of the actual error number.
Problem is a confusion about the return values between
libmpathcmd and uxsock.c.
uxsock.c is assuming a negative return value to be the errno,
but libmpathcmd is returning -1 on error and setting errno.
Signed-off-by: Hannes Reinecke <hare@suse.com>
*reply = NULL;
len = mpath_recv_reply_len(fd, timeout);
if (len <= 0)
+ return len;
+ if (len > MAX_REPLY_LEN) {
+ errno = EINVAL;
return -1;
+ }
*reply = malloc(len);
if (!*reply)
return -1;
*/
int send_packet(int fd, const char *buf)
{
- return mpath_send_cmd(fd, buf);
+ if (mpath_send_cmd(fd, buf) < 0)
+ return -errno;
+ return 0;
}
static int _recv_packet(int fd, char **buf, unsigned int timeout, ssize_t limit)
*buf = NULL;
len = mpath_recv_reply_len(fd, timeout);
- if (len <= 0)
+ if (len == 0)
return len;
+ if (len < 0)
+ return -errno;
if ((limit > 0) && (len > limit))
return -EINVAL;
(*buf) = MALLOC(len);
if (err != 0) {
FREE(*buf);
(*buf) = NULL;
+ return -errno;
}
return err;
}