3b142bdd64144135cfafc2e4c49df29ec3673238
[openwrt/openwrt.git] / package / utils / busybox / patches / 600-cve-2017-16544.patch
1 From c3797d40a1c57352192c6106cc0f435e7d9c11e8 Mon Sep 17 00:00:00 2001
2 From: Denys Vlasenko <vda.linux@googlemail.com>
3 Date: Tue, 7 Nov 2017 18:09:29 +0100
4 Subject: lineedit: do not tab-complete any strings which have control
5 characters
6
7 function old new delta
8 add_match 41 68 +27
9
10 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 ---
12 libbb/lineedit.c | 12 ++++++++++++
13 1 file changed, 12 insertions(+)
14
15 --- a/libbb/lineedit.c
16 +++ b/libbb/lineedit.c
17 @@ -633,6 +633,18 @@ static void free_tab_completion_data(voi
18
19 static void add_match(char *matched)
20 {
21 + unsigned char *p = (unsigned char*)matched;
22 + while (*p) {
23 + /* ESC attack fix: drop any string with control chars */
24 + if (*p < ' '
25 + || (!ENABLE_UNICODE_SUPPORT && *p >= 0x7f)
26 + || (ENABLE_UNICODE_SUPPORT && *p == 0x7f)
27 + ) {
28 + free(matched);
29 + return;
30 + }
31 + p++;
32 + }
33 matches = xrealloc_vector(matches, 4, num_matches);
34 matches[num_matches] = matched;
35 num_matches++;