]> sourceware.org Git - glibc.git/commitdiff
resolv: ns_name_pton should report trailing \ as error [BZ #22413]
authorFlorian Weimer <fweimer@redhat.com>
Sat, 11 Nov 2017 10:41:45 +0000 (11:41 +0100)
committerFlorian Weimer <fweimer@redhat.com>
Sat, 11 Nov 2017 10:41:45 +0000 (11:41 +0100)
ChangeLog
resolv/ns_name.c
resolv/tst-ns_name_pton.c

index 5ddb6fdc46ac200acc1957bb5e27611271521e97..4739e62246c89db30ecb8bbca9a14d5a57b13b2f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2017-11-11  Florian Weimer  <fweimer@redhat.com>
+
+       [BZ #22413]
+       * resolv/ns_name.c (ns_name_pton): Treat trailing backslash as error.
+       * resolv/tst-ns_name_pton.c (tests): Add trailing backslash tests.
+
 2017-11-11  Florian Weimer  <fweimer@redhat.com>
 
        * resolv/tst-ns_name_pton.c: New file.
index 08a75e2fe0b4edd64f6e6609d88806f54b57fa51..73213fee2dca530baf1abcb6dc52024db9d40060 100644 (file)
@@ -222,6 +222,11 @@ ns_name_pton(const char *src, u_char *dst, size_t dstsiz)
                }
                *bp++ = (u_char)c;
        }
+       if (escaped) {
+               /* Trailing backslash.  */
+               __set_errno (EMSGSIZE);
+               return -1;
+       }
        c = (bp - label - 1);
        if ((c & NS_CMPRSFLGS) != 0) {          /*%< Label too big. */
                __set_errno (EMSGSIZE);
index 879d97c9d3816210a4aa3b64f019d83e4189e227..73bdb05e08e405dc0a9950e5940c635edfb0d96f 100644 (file)
@@ -127,6 +127,13 @@ static const struct test_case tests[] =
       "\377\377", NULL, },
     { STRING63OCT "." STRING63OCT "." STRING63OCT "." STRING60OCT
       "\377\377\377", NULL, },
+    { "\\", NULL, },
+    { "\\\\", "\\\\", false },
+    { "\\\\.", "\\\\", true },
+    { "\\\\\\", NULL, },
+    { "a\\", NULL, },
+    { "a.\\", NULL, },
+    { "a.b\\", NULL, },
   };
 
 static int
This page took 0.294952 seconds and 5 git commands to generate.