Chromium Code Reviews

Side by Side Diff: fusl/src/network/dns_parse.c

Issue 1714623002: [fusl] clang-format fusl (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: headers too Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
OLDNEW
1 #include <string.h> 1 #include <string.h>
2 2
3 int __dns_parse(const unsigned char *r, int rlen, int (*callback)(void *, int, c onst void *, int, const void *), void *ctx) 3 int __dns_parse(const unsigned char* r,
4 { 4 int rlen,
5 » int qdcount, ancount; 5 int (*callback)(void*, int, const void*, int, const void*),
6 » const unsigned char *p; 6 void* ctx) {
7 » int len; 7 int qdcount, ancount;
8 const unsigned char* p;
9 int len;
8 10
9 » if (rlen<12) return -1; 11 if (rlen < 12)
10 » if ((r[3]&15)) return 0; 12 return -1;
11 » p = r+12; 13 if ((r[3] & 15))
12 » qdcount = r[4]*256 + r[5]; 14 return 0;
13 » ancount = r[6]*256 + r[7]; 15 p = r + 12;
14 » if (qdcount+ancount > 64) return -1; 16 qdcount = r[4] * 256 + r[5];
15 » while (qdcount--) { 17 ancount = r[6] * 256 + r[7];
16 » » while (p-r < rlen && *p-1U < 127) p++; 18 if (qdcount + ancount > 64)
17 » » if (*p>193 || (*p==193 && p[1]>254) || p>r+rlen-6) 19 return -1;
18 » » » return -1; 20 while (qdcount--) {
19 » » p += 5 + !!*p; 21 while (p - r < rlen && *p - 1U < 127)
20 » } 22 p++;
21 » while (ancount--) { 23 if (*p > 193 || (*p == 193 && p[1] > 254) || p > r + rlen - 6)
22 » » while (p-r < rlen && *p-1U < 127) p++; 24 return -1;
23 » » if (*p>193 || (*p==193 && p[1]>254) || p>r+rlen-6) 25 p += 5 + !!*p;
24 » » » return -1; 26 }
25 » » p += 1 + !!*p; 27 while (ancount--) {
26 » » len = p[8]*256 + p[9]; 28 while (p - r < rlen && *p - 1U < 127)
27 » » if (p+len > r+rlen) return -1; 29 p++;
28 » » if (callback(ctx, p[1], p+10, len, r) < 0) return -1; 30 if (*p > 193 || (*p == 193 && p[1] > 254) || p > r + rlen - 6)
29 » » p += 10 + len; 31 return -1;
30 » } 32 p += 1 + !!*p;
31 » return 0; 33 len = p[8] * 256 + p[9];
34 if (p + len > r + rlen)
35 return -1;
36 if (callback(ctx, p[1], p + 10, len, r) < 0)
37 return -1;
38 p += 10 + len;
39 }
40 return 0;
32 } 41 }
OLDNEW

Powered by Google App Engine