Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(400)

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

Issue 1573973002: Add a "fork" of musl as //fusl. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « fusl/src/network/dn_comp.c ('k') | fusl/src/network/dn_skipname.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #include <resolv.h>
2 #include "libc.h"
3
4 int __dn_expand(const unsigned char *base, const unsigned char *end, const unsig ned char *src, char *dest, int space)
5 {
6 const unsigned char *p = src;
7 char *dend, *dbegin = dest;
8 int len = -1, i, j;
9 if (p==end || space <= 0) return -1;
10 dend = dest + (space > 254 ? 254 : space);
11 /* detect reference loop using an iteration counter */
12 for (i=0; i < end-base; i+=2) {
13 /* loop invariants: p<end, dest<dend */
14 if (*p & 0xc0) {
15 if (p+1==end) return -1;
16 j = ((p[0] & 0x3f) << 8) | p[1];
17 if (len < 0) len = p+2-src;
18 if (j >= end-base) return -1;
19 p = base+j;
20 } else if (*p) {
21 if (dest != dbegin) *dest++ = '.';
22 j = *p++;
23 if (j >= end-p || j >= dend-dest) return -1;
24 while (j--) *dest++ = *p++;
25 } else {
26 *dest = 0;
27 if (len < 0) len = p+1-src;
28 return len;
29 }
30 }
31 return -1;
32 }
33
34 weak_alias(__dn_expand, dn_expand);
OLDNEW
« no previous file with comments | « fusl/src/network/dn_comp.c ('k') | fusl/src/network/dn_skipname.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698