Browse Source

recv_unix_msg can return a dud buffer on select failure

master
Con Kolivas 11 years ago
parent
commit
3107450281
  1. 3
      src/libckpool.c

3
src/libckpool.c

@ -672,13 +672,12 @@ char *_recv_unix_msg(int sockd, const char *file, const char *func, const int li
LOGWARNING("Invalid message length zero sent to recv_unix_msg"); LOGWARNING("Invalid message length zero sent to recv_unix_msg");
goto out; goto out;
} }
buf = ckalloc(msglen + 1);
buf[msglen] = 0;
ret = wait_read_select(sockd, 5); ret = wait_read_select(sockd, 5);
if (unlikely(ret < 1)) { if (unlikely(ret < 1)) {
LOGERR("Select2 failed in recv_unix_msg"); LOGERR("Select2 failed in recv_unix_msg");
goto out; goto out;
} }
buf = ckzalloc(msglen + 1);
ret = read_length(sockd, buf, msglen); ret = read_length(sockd, buf, msglen);
if (unlikely(ret < (int)msglen)) { if (unlikely(ret < (int)msglen)) {
LOGERR("Failed to read %d bytes in recv_unix_msg", msglen); LOGERR("Failed to read %d bytes in recv_unix_msg", msglen);

Loading…
Cancel
Save