Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

hpclient.c msglen bug

  • Loading branch information...
commit 9d410dbb7d460aba9b899b6fa7e5f043da6be45d 1 parent 305f46b
@bg6cq bg6cq authored
Showing with 4 additions and 3 deletions.
  1. +4 −3 libhpfeeds/tools/hpclient.c
View
7 libhpfeeds/tools/hpclient.c
@@ -44,19 +44,20 @@ u_char *read_msg(int s) {
u_char *buffer;
u_int32_t msglen;
- if (read(s, &msglen, 4) == -1) {
+ if (read(s, &msglen, 4) != 4) {
perror("read()");
exit(EXIT_FAILURE);
}
- if ((buffer = malloc(msglen)) == NULL) {
+ if ((buffer = malloc(ntohl(msglen))) == NULL) {
perror("malloc()");
exit(EXIT_FAILURE);
}
*(u_int32_t *) buffer = msglen;
+ msglen = ntohl(msglen);
- if (read(s, buffer + 4, msglen - 4) == -1) {
+ if (read(s, buffer + 4, msglen - 4) != (msglen - 4)) {
perror("read()");
exit(EXIT_FAILURE);
}
Please sign in to comment.
Something went wrong with that request. Please try again.