mirror of
https://github.com/yarrick/iodine.git
synced 2024-11-27 12:05:15 +00: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 qdcount;
|
||||||
short ancount;
|
short ancount;
|
||||||
uint32_t ttl;
|
uint32_t ttl;
|
||||||
short class;
|
unsigned short class;
|
||||||
short type;
|
unsigned short type;
|
||||||
char *data;
|
char *data;
|
||||||
short rlen;
|
unsigned short rlen;
|
||||||
int id;
|
int id;
|
||||||
int rv;
|
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 names[250][QUERY_NAME_SIZE];
|
||||||
char *rdatastart;
|
char *rdatastart;
|
||||||
short pref;
|
unsigned short pref;
|
||||||
int i;
|
int i;
|
||||||
int offset;
|
int offset;
|
||||||
|
|
||||||
|
@ -85,15 +85,15 @@ readname(char *packet, int packetlen, char **src, char *dst, size_t length)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
readshort(char *packet, char **src, short *dst)
|
readshort(char *packet, char **src, unsigned short *dst)
|
||||||
{
|
{
|
||||||
unsigned char *p;
|
unsigned char *p;
|
||||||
|
|
||||||
p = (unsigned char *) *src;
|
p = (unsigned char *) *src;
|
||||||
*dst = (p[0] << 8) | p[1];
|
*dst = (p[0] << 8) | p[1];
|
||||||
|
|
||||||
(*src) += sizeof(short);
|
(*src) += sizeof(unsigned short);
|
||||||
return sizeof(short);
|
return sizeof(unsigned short);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#define _READ_H_
|
#define _READ_H_
|
||||||
|
|
||||||
int readname(char *, int, char **, char *, size_t);
|
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 readlong(char *, char **, uint32_t *);
|
||||||
int readdata(char *, char **, char *, size_t);
|
int readdata(char *, char **, char *, size_t);
|
||||||
int readtxtbin(char *, char **, size_t, 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);
|
i, ntohs(k), i);
|
||||||
|
|
||||||
p = (char*)&k;
|
p = (char*)&k;
|
||||||
readshort(NULL, &p, (short *) &l);
|
readshort(NULL, &p, &l);
|
||||||
fail_unless(l == i,
|
fail_unless(l == i,
|
||||||
"Bad value on readshort for %d: %d != %d",
|
"Bad value on readshort for %d: %d != %d",
|
||||||
i, l, i);
|
i, l, i);
|
||||||
|
Loading…
Reference in New Issue
Block a user