diff options
author | Daniel Stenberg <daniel@haxx.se> | 2018-10-04 11:57:29 +0200 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2018-10-05 22:15:34 +0200 |
commit | 7f00146d0098e585727a219d4835800bc862b31d (patch) | |
tree | ecdf43ec07706105c720021de7be264b62bfeda8 /tests | |
parent | ec49132faf0c8c42e08f4c77bb14988fd57075cb (diff) | |
download | curl-7f00146d0098e585727a219d4835800bc862b31d.tar.gz |
doh: keep the IPv4 address in (original) network byte order
Ideally this will fix the reversed order shown in SPARC tests:
resp 8: Expected 127.0.0.1 got 1.0.0.127
Closes #3091
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/unit1650.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/tests/unit/unit1650.c b/tests/unit/unit1650.c index 05024f9b2..723c06421 100644 --- a/tests/unit/unit1650.c +++ b/tests/unit/unit1650.c @@ -155,6 +155,7 @@ UNITTEST_START size_t size; unsigned char buffer[256]; size_t i; + unsigned char *p; for(i = 0; i < sizeof(req) / sizeof(req[0]); i++) { int rc = doh_encode(req[i].name, req[i].type, buffer, sizeof(buffer), &size); @@ -198,9 +199,8 @@ UNITTEST_START struct dohaddr *a; a = &d.addr[u]; if(resp[i].type == DNS_TYPE_A) { - snprintf(ptr, len, "%d.%d.%d.%d ", - a->ip.v4 & 0xff, (a->ip.v4>>8) & 0xff, - (a->ip.v4>>16) & 0xff, a->ip.v4 >>24); + p = &a->ip.v4[0]; + snprintf(ptr, len, "%u.%u.%u.%u ", p[0], p[1], p[2], p[3]); o = strlen(ptr); len -= o; ptr += o; @@ -209,8 +209,8 @@ UNITTEST_START int j; for(j = 0; j < 16; j += 2) { size_t l; - snprintf(ptr, len, "%s%02x%02x", j?":":"", a->ip.v6.byte[j], - a->ip.v6.byte[j + 1]); + snprintf(ptr, len, "%s%02x%02x", j?":":"", a->ip.v6[j], + a->ip.v6[j + 1]); l = strlen(ptr); len -= l; ptr += l; @@ -270,9 +270,9 @@ UNITTEST_START DNS_TYPE_A, &d); fail_if(d.numaddr != 1, "missing address"); a = &d.addr[0]; - snprintf((char *)buffer, sizeof(buffer), "%d.%d.%d.%d", - a->ip.v4 & 0xff, (a->ip.v4>>8) & 0xff, - (a->ip.v4>>16) & 0xff, a->ip.v4 >>24); + p = &a->ip.v4[0]; + snprintf((char *)buffer, sizeof(buffer), + "%u.%u.%u.%u", p[0], p[1], p[2], p[3]); if(rc || strcmp((char *)buffer, "127.0.0.1")) { fprintf(stderr, "bad address decoded: %s, rc == %d\n", buffer, rc); return 7; |