Please Don't Compile With musl
Closed this issue · 5 comments
cpktpoetkxwz commented
There is a bug in ns_skiprr function of musl, which make ns_initparse return -1 everytime.
int ns_skiprr(const unsigned char *ptr, const unsigned char *eom, ns_sect section, int count)
{
const unsigned char *p = ptr;
int r;
while (count--) {
r = dn_skipname(p, eom);
if (r < 0) goto bad;
if (r + 2 * NS_INT16SZ > eom - p) goto bad;
p += r + 2 * NS_INT16SZ;
if (section != ns_s_qd) {
if (NS_INT32SZ + NS_INT16SZ > eom - p) goto bad;
p += NS_INT32SZ;
NS_GET16(r, p);
if (r > eom - p) goto bad;
p += r;
}
}
return ptr - p; /*should be p - ptr */
bad:
errno = EMSGSIZE;
return -1;
}
If you want to compile ChinaDNS yourself, please compile with uclibc.
Otherwise, you need to create a patch and place it to toolchain/musl/patches.
The patch:
--- a/src/network/ns_parse.c
+++ b/src/network/ns_parse.c
@@ -95,7 +95,7 @@ int ns_skiprr(const unsigned char *ptr, const unsigned char *eom, ns_sect sectio
p += r;
}
}
- return ptr - p;
+ return p - ptr;
bad:
errno = EMSGSIZE;
return -1;
cpktpoetkxwz commented
leenchan commented
thank you~ finally know the problem.
wongsyrone commented
this patch already merged: http://git.musl-libc.org/cgit/musl/commit/?id=e8cbe0bad4284906230a53af4c91ad2b9713d03b
Thank you.
wongsyrone commented
If you want to compile with musl-libc for OpenWrt, please update your codebase to openwrt-mirror/openwrt@365634d
@Pentiumluyu In my opinion, it's time to close this issue.
cpktpoetkxwz commented
@wongsyrone Agree