mirror of
https://github.com/yarrick/iodine.git
synced 2024-11-26 10:09:19 +02:00
Small fixes, not working yet
This commit is contained in:
parent
b52787a74b
commit
783399e901
7
read.c
7
read.c
|
@ -41,20 +41,19 @@ readname_loop(char *packet, char **src, char *dst, size_t length, size_t loop)
|
|||
break;
|
||||
}
|
||||
|
||||
while(c && len < length - 2) {
|
||||
while(c && len < length - 1) {
|
||||
*d++ = *s++;
|
||||
len++;
|
||||
|
||||
c--;
|
||||
}
|
||||
|
||||
if (*s != 0 && len < length - 2)
|
||||
if (*s != 0 && len < length - 1)
|
||||
*d++ = '.';
|
||||
}
|
||||
(*src) = s+1;
|
||||
|
||||
dst[len] = '\0';
|
||||
|
||||
dst[len++] = '\0';
|
||||
return len;
|
||||
}
|
||||
|
||||
|
|
17
test.c
17
test.c
|
@ -104,6 +104,7 @@ test_readputlong()
|
|||
printf("OK\n");
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
test_readname()
|
||||
{
|
||||
|
@ -113,6 +114,15 @@ test_readname()
|
|||
char infloop[] = {
|
||||
'A', 'A', 0x81, 0x80, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x01, 'A', 0xc0, 0x0c, 0x00, 0x01, 0x00, 0x01 };
|
||||
char longname[] =
|
||||
"AA\x81\x80\x00\x01\x00\x00\x00\x00\x00\x00"
|
||||
"\x3FzBCDEFGHIJKLMNOPQURSTUVXYZ0123456789abcdefghijklmnopqrstuvxyzAA"
|
||||
"\x3FzBCDEFGHIJKLMNOPQURSTUVXYZ0123456789abcdefghijklmnopqrstuvxyzAA"
|
||||
"\x3FzBCDEFGHIJKLMNOPQURSTUVXYZ0123456789abcdefghijklmnopqrstuvxyzAA"
|
||||
"\x3FzBCDEFGHIJKLMNOPQURSTUVXYZ0123456789abcdefghijklmnopqrstuvxyzAA"
|
||||
"\x3FzBCDEFGHIJKLMNOPQURSTUVXYZ0123456789abcdefghijklmnopqrstuvxyzAA"
|
||||
"\x3FzBCDEFGHIJKLMNOPQURSTUVXYZ0123456789abcdefghijklmnopqrstuvxyzAA"
|
||||
"\x00\x01\x00\x01";
|
||||
char buf[1024];
|
||||
char *data;
|
||||
int rv;
|
||||
|
@ -132,6 +142,13 @@ test_readname()
|
|||
rv = readname(infloop, &data, buf, 4);
|
||||
assert(buf[4] == '\a');
|
||||
|
||||
bzero(buf, sizeof(buf));
|
||||
data = longname + sizeof(HEADER);
|
||||
buf[256] = '\a';
|
||||
rv = readname(longname, &data, buf, 256);
|
||||
printf("got %d, '%s' len %d \n", rv, buf, strlen(buf));
|
||||
assert(buf[256] == '\a');
|
||||
|
||||
printf("OK\n");
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue