Skip to content

Commit

Permalink
Fix some bugs.
Browse files Browse the repository at this point in the history
  • Loading branch information
vstakhov committed Apr 2, 2014
1 parent f3cace2 commit 897b0bc
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/compression.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
*/

#include "compression.h"
#include "logger.h"

static struct rdns_compression_entry *
rdns_can_compress (const char *pos, struct rdns_compression_entry *comp)
Expand All @@ -44,6 +45,7 @@ rdns_calculate_label_len (const char *pos, const char *end)
break;
}
res ++;
p ++;
}
return res;
}
Expand Down Expand Up @@ -91,15 +93,15 @@ rdns_write_name_compressed (struct rdns_request *req,
uint16_t pointer;

while (pos < end && remain > 0) {
if (head == NULL) {
if (head != NULL) {
test = rdns_can_compress (pos, head);
if (test != NULL) {
if (remain < 2) {
rdns_info ("no buffer remain for constructing query");
return false;
}

pointer = htons ((uint16_t)test->offset | DNS_COMPRESSION_BITS);
pointer = htons ((uint16_t)test->offset) | DNS_COMPRESSION_BITS;
memcpy (target, &pointer, sizeof (pointer));
req->pos += 2;

Expand Down

0 comments on commit 897b0bc

Please sign in to comment.