Skip to content

Commit 9e0ad30

Browse files
committed
resolv: ns_name_pton should report trailing \ as error [BZ #22413]
1 parent e2a9fca commit 9e0ad30

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

ChangeLog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
2017-11-11 Florian Weimer <[email protected]>
2+
3+
[BZ #22413]
4+
* resolv/ns_name.c (ns_name_pton): Treat trailing backslash as error.
5+
* resolv/tst-ns_name_pton.c (tests): Add trailing backslash tests.
6+
17
2017-11-11 Florian Weimer <[email protected]>
28

39
* resolv/tst-ns_name_pton.c: New file.

resolv/ns_name.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,11 @@ ns_name_pton(const char *src, u_char *dst, size_t dstsiz)
222222
}
223223
*bp++ = (u_char)c;
224224
}
225+
if (escaped) {
226+
/* Trailing backslash. */
227+
__set_errno (EMSGSIZE);
228+
return -1;
229+
}
225230
c = (bp - label - 1);
226231
if ((c & NS_CMPRSFLGS) != 0) { /*%< Label too big. */
227232
__set_errno (EMSGSIZE);

resolv/tst-ns_name_pton.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,13 @@ static const struct test_case tests[] =
127127
"\377\377", NULL, },
128128
{ STRING63OCT "." STRING63OCT "." STRING63OCT "." STRING60OCT
129129
"\377\377\377", NULL, },
130+
{ "\\", NULL, },
131+
{ "\\\\", "\\\\", false },
132+
{ "\\\\.", "\\\\", true },
133+
{ "\\\\\\", NULL, },
134+
{ "a\\", NULL, },
135+
{ "a.\\", NULL, },
136+
{ "a.b\\", NULL, },
130137
};
131138

132139
static int

0 commit comments

Comments
 (0)