mirror of
https://github.com/yarrick/iodine.git
synced 2024-11-21 20:46:06 +03:00
Change readshort() to work with unsigned values
This commit is contained in:
parent
1f4b9250cf
commit
2466cd184a
@ -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;
|
||||
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user