Change readshort() to work with unsigned values

This commit is contained in:
Erik Ekman 2014-06-09 19:47:44 +02:00
parent 1f4b9250cf
commit 2466cd184a
4 changed files with 9 additions and 9 deletions

View file

@ -404,10 +404,10 @@ dns_decode(char *buf, size_t buflen, struct query *q, qr_t qr, char *packet, siz
short qdcount;
short ancount;
uint32_t ttl;
short class;
short type;
unsigned short class;
unsigned short type;
char *data;
short rlen;
unsigned short rlen;
int id;
int rv;
@ -509,7 +509,7 @@ dns_decode(char *buf, size_t buflen, struct query *q, qr_t qr, char *packet, siz
*/
char names[250][QUERY_NAME_SIZE];
char *rdatastart;
short pref;
unsigned short pref;
int i;
int offset;

View file

@ -85,15 +85,15 @@ readname(char *packet, int packetlen, char **src, char *dst, size_t length)
}
int
readshort(char *packet, char **src, short *dst)
readshort(char *packet, char **src, unsigned short *dst)
{
unsigned char *p;
p = (unsigned char *) *src;
*dst = (p[0] << 8) | p[1];
(*src) += sizeof(short);
return sizeof(short);
(*src) += sizeof(unsigned short);
return sizeof(unsigned short);
}
int

View file

@ -19,7 +19,7 @@
#define _READ_H_
int readname(char *, int, char **, char *, size_t);
int readshort(char *, char **, short *);
int readshort(char *, char **, unsigned short *);
int readlong(char *, char **, uint32_t *);
int readdata(char *, char **, char *, size_t);
int readtxtbin(char *, char **, size_t, char *, size_t);

View file

@ -51,7 +51,7 @@ START_TEST(test_read_putshort)
i, ntohs(k), i);
p = (char*)&k;
readshort(NULL, &p, (short *) &l);
readshort(NULL, &p, &l);
fail_unless(l == i,
"Bad value on readshort for %d: %d != %d",
i, l, i);