void-packages/srcpkgs/wine/patches/musl-ns_name_skip.patch
2021-10-23 16:43:42 +02:00

48 lines
1 KiB
Diff

diff --git a/dlls/dnsapi/libresolv.c b/dlls/dnsapi/libresolv.c
index ac52147..0f8c2ef 100644
--- a/wine-6.20/dlls/dnsapi/libresolv.c
+++ b/wine-6.20/dlls/dnsapi/libresolv.c
@@ -57,6 +57,43 @@
WINE_DEFAULT_DEBUG_CHANNEL(dnsapi);
+/* code from glibc's resolv/ns_name.c, with errno setting removed */
+/*%
+ * Advance *ptrptr to skip over the compressed name it points at.
+ *
+ * return:
+ *\li 0 on success, -1 (with errno set) on failure.
+ */
+#ifndef __GLIBC__
+static int
+ns_name_skip(const u_char **ptrptr, const u_char *eom)
+{
+ const u_char *cp;
+ u_int n;
+
+ cp = *ptrptr;
+ while (cp < eom && (n = *cp++) != 0) {
+ /* Check for indirection. */
+ switch (n & NS_CMPRSFLGS) {
+ case 0: /*%< normal case, n == len */
+ cp += n;
+ continue;
+ case NS_CMPRSFLGS: /*%< indirection */
+ cp++;
+ break;
+ default: /*%< illegal type */
+ return (-1);
+ }
+ break;
+ }
+ if (cp > eom) {
+ return (-1);
+ }
+ *ptrptr = cp;
+ return (0);
+}
+#endif
+
static const char *debugstr_type( unsigned short type )
{
const char *str;