mirror of
https://github.com/yarrick/iodine.git
synced 2024-11-22 13:06:06 +03:00
rewrite comparison to avoid negative unsigned numbers
Note that GCC -O2 is happy to optimize away (x<0) when x is an unsigned quantity. This was actually occurring in CHECKLEN(0), causing the compiler to issue a warning.
This commit is contained in:
parent
ee1c49a383
commit
f73fb9f8d0
@ -45,7 +45,7 @@
|
||||
|
||||
int dnsc_use_edns0 = 1;
|
||||
|
||||
#define CHECKLEN(x) if (buflen - (p-buf) < (x)) return 0
|
||||
#define CHECKLEN(x) if (buflen < (x) + (unsigned)(p-buf)) return 0
|
||||
|
||||
int
|
||||
dns_encode(char *buf, size_t buflen, struct query *q, qr_t qr, char *data, size_t datalen)
|
||||
@ -391,7 +391,7 @@ dns_get_id(char *packet, size_t packetlen)
|
||||
return ntohs(header->id);
|
||||
}
|
||||
|
||||
#define CHECKLEN(x) if (packetlen - (data-packet) < (x)) return 0
|
||||
#define CHECKLEN(x) if (packetlen < (x) + (unsigned)(data-packet)) return 0
|
||||
|
||||
int
|
||||
dns_decode(char *buf, size_t buflen, struct query *q, qr_t qr, char *packet, size_t packetlen)
|
||||
|
Loading…
Reference in New Issue
Block a user