From patchwork Sat Nov 11 10:44:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 24200 Received: (qmail 8930 invoked by alias); 11 Nov 2017 10:44:44 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 8404 invoked by uid 89); 11 Nov 2017 10:44:43 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:1221 X-HELO: mx1.redhat.com Date: Sat, 11 Nov 2017 11:44:40 +0100 To: libc-alpha@sourceware.org Subject: [PATCH COMMITTED] resolv: ns_name_pton should report trailing \ as error [BZ #22413] User-Agent: Heirloom mailx 12.5 7/5/10 MIME-Version: 1.0 Message-Id: <20171111104440.858F5439942E9@oldenburg.str.redhat.com> From: fweimer@redhat.com (Florian Weimer) 2017-11-11 Florian Weimer [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. diff --git a/resolv/ns_name.c b/resolv/ns_name.c index 08a75e2fe0..73213fee2d 100644 --- a/resolv/ns_name.c +++ b/resolv/ns_name.c @@ -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); diff --git a/resolv/tst-ns_name_pton.c b/resolv/tst-ns_name_pton.c index 879d97c9d3..73bdb05e08 100644 --- a/resolv/tst-ns_name_pton.c +++ b/resolv/tst-ns_name_pton.c @@ -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