Commit Diff


commit - de16f13656e735233215439c688a6c68c1fbd97c
commit + 63f681aa40858cecf5441a32466e723432928f12
blob - adfb0cf05d963eee969f814403b2535b02042d5f
blob + 4f46a4a6100f51eddfb822e354d336daa0c77cb9
--- client.c
+++ client.c
@@ -246,19 +246,27 @@ client_send_listener(int type, const void *data, uint1
 }
 
 static inline void
-parse_message(void *data, size_t len, struct np_msg_header *hdr, void **cnt)
+parse_message(uint8_t *data, size_t len, struct np_msg_header *hdr, void **cnt)
 {
 	if (len < 4)
 		goto err;
 
-	memcpy(hdr, data, sizeof(*hdr));
+	memcpy(&hdr->len, data, sizeof(hdr->len));
+	data += sizeof(hdr->len);
 
+	memcpy(&hdr->type, data, sizeof(hdr->type));
+	data += sizeof(hdr->type);
+
+	memcpy(&hdr->tag, data, sizeof(hdr->tag));
+	data += sizeof(hdr->tag);
+
 	hdr->len = le32toh(hdr->len);
+	/* type is one byte long, no endianness issues */
+	hdr->tag = le16toh(hdr->tag);
 
 	if (len != hdr->len)
 		goto err;
 
-	/* type is one byte long, no endianness issues */
 	if (hdr->type < Tversion ||
 	    hdr->type >= Tmax    ||
 	    hdr->type == Terror  ||
@@ -278,6 +286,9 @@ err:
 static inline void
 np_header(uint32_t len, uint8_t type, uint16_t tag)
 {
+	len = htole32(len);
+	tag = htole16(tag);
+
 	evbuffer_add(evb, &len, sizeof(len));
 	evbuffer_add(evb, &type, sizeof(type));
 	evbuffer_add(evb, &tag, sizeof(tag));