mirror of
https://github.com/yarrick/iodine.git
synced 2024-11-23 00:29:20 +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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
while(c && len < length - 2) {
|
while(c && len < length - 1) {
|
||||||
*d++ = *s++;
|
*d++ = *s++;
|
||||||
len++;
|
len++;
|
||||||
|
|
||||||
c--;
|
c--;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*s != 0 && len < length - 2)
|
if (*s != 0 && len < length - 1)
|
||||||
*d++ = '.';
|
*d++ = '.';
|
||||||
}
|
}
|
||||||
(*src) = s+1;
|
(*src) = s+1;
|
||||||
|
|
||||||
dst[len] = '\0';
|
dst[len++] = '\0';
|
||||||
|
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
17
test.c
17
test.c
|
@ -104,6 +104,7 @@ test_readputlong()
|
||||||
printf("OK\n");
|
printf("OK\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_readname()
|
test_readname()
|
||||||
{
|
{
|
||||||
|
@ -113,6 +114,15 @@ test_readname()
|
||||||
char infloop[] = {
|
char infloop[] = {
|
||||||
'A', 'A', 0x81, 0x80, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
'A', 'A', 0x81, 0x80, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
0x01, 'A', 0xc0, 0x0c, 0x00, 0x01, 0x00, 0x01 };
|
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 buf[1024];
|
||||||
char *data;
|
char *data;
|
||||||
int rv;
|
int rv;
|
||||||
|
@ -132,6 +142,13 @@ test_readname()
|
||||||
rv = readname(infloop, &data, buf, 4);
|
rv = readname(infloop, &data, buf, 4);
|
||||||
assert(buf[4] == '\a');
|
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");
|
printf("OK\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue