inet_pton tests, fix regression test case
[libc-test.git] / src / regression / dn_expand-ptr-0.c
blobbeca2d3431f3d6e3c18a60e545af067327ff6794
1 // dn_expand should handle offset pointer to 0 byte
2 #define _BSD_SOURCE
3 #include <resolv.h>
4 #include <string.h>
5 #include "test.h"
7 int main(void)
9 unsigned char packet[] = {2,'p','q',0xc0,5,0};
10 char name[] = "XXXX";
11 int r;
13 /* non-empty name with pointer to 0 */
14 r = dn_expand(packet, packet+6, packet, name, 3);
15 if (r!=5)
16 t_error("dn_expand(\"\\2pq\\xc0\\5\", name, 3) returned %d, wanted 5\n", r);
17 if (strcmp(name, "pq"))
18 t_error("dn_expand(\"\\2pq\\xc0\\5\", name, 3) failed: got \"%s\" name, wanted \"pq\"\n", name);
20 /* empty name with pointer to 0 */
21 memcpy(packet, "\xc0\2", 3);
22 memcpy(name, "XXXX", 5);
23 r = dn_expand(packet, packet+3, packet, name, 1);
24 if (r!=2)
25 t_error("dn_expand(\"\\xc0\\2\", name, 1) returned %d, wanted 2\n", r);
26 if (name[0])
27 t_error("dn_expand(\"\\xc0\\2\", name, 1) failed: got \"%s\" name, wanted \"\"\n", name);
29 return t_status;