X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Ffunctional%2Finet_pton.c;h=b31faed5537c3d2e5c3fca92a8d45f0fe4c3520c;hb=2113a3ed8217775797dd9a82aa420c10ef1712d5;hp=188b68a478e3e0bfe1318ba2419ef1c0b400abd7;hpb=c5b587059e242179b44156af52552bb60c970204;p=libc-test diff --git a/src/functional/inet_pton.c b/src/functional/inet_pton.c index 188b68a..b31faed 100644 --- a/src/functional/inet_pton.c +++ b/src/functional/inet_pton.c @@ -28,9 +28,9 @@ static void tohex(char *d, void *s, int n) #define V6(src,ret,hex) do{\ int r; \ - char binaddr[16]; \ - char hexaddr[40]; \ - char txtaddr[60]; \ + char binaddr[16]={0}; \ + char hexaddr[40]={0}; \ + char txtaddr[60]={0}; \ \ r=inet_pton(AF_INET6,src,binaddr); \ if (r!=ret) \ @@ -57,7 +57,7 @@ static void tohex(char *d, void *s, int n) int r; \ uint32_t a; \ struct in_addr in; \ - char buf[20]; \ + char buf[20]={0}; \ char *p; \ \ a=inet_addr(src); \ @@ -94,11 +94,10 @@ int main(void) if (inet_pton(12345, "", 0) != -1 || errno != EAFNOSUPPORT) t_error("inet_pton(12345,,) should fail with EAFNOSUPPORT, got %s\n", strerror(errno)); errno=0; -if (inet_ntop(AF_INET,"xxxx",0,0) != -1 || errno != ENOSPC) +if (inet_ntop(AF_INET,"xxxx","",0) != 0 || errno != ENOSPC) t_error("inet_ntop(,,0,0) should fail with ENOSPC, got %s\n", strerror(errno)); errno=0; - // dotted-decimal notation V4("0.0.0.0", 1, "00000000") V4("127.0.0.1", 1, "7f000001") @@ -139,7 +138,15 @@ V6(":ffff:192.168.1.1", 0, "") V6("::ffff:192.168.1.1", 1, "00000000000000000000ffffc0a80101") V6(".192.168.1.1", 0, "") V6(":.192.168.1.1", 0, "") -V6("a:0b:00c:000d:0000e:f::", 1, "000a000b000c000d000e000f00000000") +V6("a:0b:00c:000d:E:F::", 1, "000a000b000c000d000e000f00000000") +V6("a:0b:00c:000d:0000e:f::", 0, "") +V6("1:2:3:4:5:6::", 1, "00010002000300040005000600000000") +V6("1:2:3:4:5:6:7::", 1, "00010002000300040005000600070000") +V6("1:2:3:4:5:6:7:8::", 0, "") +V6("1:2:3:4:5:6:7::9", 0, "") +V6("::1:2:3:4:5:6", 1, "00000000000100020003000400050006") +V6("::1:2:3:4:5:6:7", 1, "00000001000200030004000500060007") +V6("::1:2:3:4:5:6:7:8", 0, "") V6("a:b::c:d:e:f", 1, "000a000b00000000000c000d000e000f") V6("ffff:c0a8:5e4", 0, "") V6(":ffff:c0a8:5e4", 0, "")