Browse Source

Add sanity check to read size for unix message in libckpool

master
ckolivas 10 years ago
parent
commit
11c04e483c
  1. 6
      src/libckpool.c

6
src/libckpool.c

@ -756,8 +756,8 @@ char *_recv_unix_msg(int sockd, const char *file, const char *func, const int li
goto out; goto out;
} }
msglen = le32toh(msglen); msglen = le32toh(msglen);
if (unlikely(msglen < 1)) { if (unlikely(msglen < 1 || msglen > 0x80000000)) {
LOGWARNING("Invalid message length zero sent to recv_unix_msg"); LOGWARNING("Invalid message length %u sent to recv_unix_msg", msglen);
goto out; goto out;
} }
ret = wait_read_select(sockd, 5); ret = wait_read_select(sockd, 5);
@ -768,7 +768,7 @@ char *_recv_unix_msg(int sockd, const char *file, const char *func, const int li
buf = ckzalloc(msglen + 1); 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 %u bytes in recv_unix_msg", msglen);
dealloc(buf); dealloc(buf);
} }
out: out:

Loading…
Cancel
Save