/[packages]/updates/5/glibc/current/SOURCES/220-posix-tst-glob-tilde.c-Add-test-for-bug-22332.patch
ViewVC logotype

Contents of /updates/5/glibc/current/SOURCES/220-posix-tst-glob-tilde.c-Add-test-for-bug-22332.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1184057 - (show annotations) (download)
Fri Dec 22 19:56:02 2017 UTC (6 years, 4 months ago) by tmb
File size: 3885 byte(s)
fix CVE-2017-1213[23], CVE-2017-1567[01], CVE-2017-15804
1 From bddc5728810859952a2acaec6302308361e828cc Mon Sep 17 00:00:00 2001
2 From: Florian Weimer <fweimer@redhat.com>
3 Date: Thu, 2 Nov 2017 11:06:45 +0100
4 Subject: [PATCH 7/8] posix/tst-glob-tilde.c: Add test for bug 22332
5
6 (cherry picked from commit 2fac6a6cd50c22ac28c97d0864306594807ade3e)
7 ---
8 ChangeLog | 7 +++++++
9 posix/tst-glob-tilde.c | 53 ++++++++++++++++++++++++++++----------------------
10 2 files changed, 37 insertions(+), 23 deletions(-)
11
12 #diff --git a/ChangeLog b/ChangeLog
13 #index 77eea1e024..172df43e16 100644
14 #--- a/ChangeLog
15 #+++ b/ChangeLog
16 ##@@ -1,3 +1,10 @@
17 #+2017-11-02 Florian Weimer <fweimer@redhat.com>
18 #+
19 #+ [BZ #22332]
20 #+ * posix/tst-glob-tilde.c (do_noescape): New variable.
21 #+ (one_test): Process it.
22 #+ (do_test): Set do_noescape. Add unescaping test case.
23 #+
24 # 2017-10-22 Paul Eggert <eggert@cs.ucla.edu>
25 #
26 # [BZ #22332]
27 diff --git a/posix/tst-glob-tilde.c b/posix/tst-glob-tilde.c
28 index 9518b4a6f8..6886f4371f 100644
29 --- a/posix/tst-glob-tilde.c
30 +++ b/posix/tst-glob-tilde.c
31 @@ -1,4 +1,4 @@
32 -/* Check for GLOB_TIDLE heap allocation issues (bug 22320, bug 22325).
33 +/* Check for GLOB_TIDLE heap allocation issues (bugs 22320, 22325, 22332).
34 Copyright (C) 2017 Free Software Foundation, Inc.
35 This file is part of the GNU C Library.
36
37 @@ -34,6 +34,9 @@ static int do_nocheck;
38 /* Flag which indicates whether to pass the GLOB_MARK flag. */
39 static int do_mark;
40
41 +/* Flag which indicates whether to pass the GLOB_NOESCAPE flag. */
42 +static int do_noescape;
43 +
44 static void
45 one_test (const char *prefix, const char *middle, const char *suffix)
46 {
47 @@ -45,6 +48,8 @@ one_test (const char *prefix, const char *middle, const char *suffix)
48 flags |= GLOB_NOCHECK;
49 if (do_mark)
50 flags |= GLOB_MARK;
51 + if (do_noescape)
52 + flags |= GLOB_NOESCAPE;
53 glob_t gl;
54 /* This glob call might result in crashes or memory leaks. */
55 if (glob (pattern, flags, NULL, &gl) == 0)
56 @@ -105,28 +110,30 @@ do_test (void)
57 for (do_onlydir = 0; do_onlydir < 2; ++do_onlydir)
58 for (do_nocheck = 0; do_nocheck < 2; ++do_nocheck)
59 for (do_mark = 0; do_mark < 2; ++do_mark)
60 - for (int base_idx = 0; base_sizes[base_idx] >= 0; ++base_idx)
61 - {
62 - for (int size_skew = -max_size_skew; size_skew <= max_size_skew;
63 - ++size_skew)
64 - {
65 - int size = base_sizes[base_idx] + size_skew;
66 - if (size < 0)
67 - continue;
68 -
69 - const char *user_name = repeating_string (size);
70 - one_test ("~", user_name, "/a/b");
71 - }
72 -
73 - const char *user_name = repeating_string (base_sizes[base_idx]);
74 - one_test ("~", user_name, "");
75 - one_test ("~", user_name, "/");
76 - one_test ("~", user_name, "/a");
77 - one_test ("~", user_name, "/*/*");
78 - one_test ("~", user_name, "\\/");
79 - one_test ("/~", user_name, "");
80 - one_test ("*/~", user_name, "/a/b");
81 - }
82 + for (do_noescape = 0; do_noescape < 2; ++do_noescape)
83 + for (int base_idx = 0; base_sizes[base_idx] >= 0; ++base_idx)
84 + {
85 + for (int size_skew = -max_size_skew; size_skew <= max_size_skew;
86 + ++size_skew)
87 + {
88 + int size = base_sizes[base_idx] + size_skew;
89 + if (size < 0)
90 + continue;
91 +
92 + const char *user_name = repeating_string (size);
93 + one_test ("~", user_name, "/a/b");
94 + one_test ("~", user_name, "x\\x\\x////x\\a");
95 + }
96 +
97 + const char *user_name = repeating_string (base_sizes[base_idx]);
98 + one_test ("~", user_name, "");
99 + one_test ("~", user_name, "/");
100 + one_test ("~", user_name, "/a");
101 + one_test ("~", user_name, "/*/*");
102 + one_test ("~", user_name, "\\/");
103 + one_test ("/~", user_name, "");
104 + one_test ("*/~", user_name, "/a/b");
105 + }
106
107 free (repeat);
108
109 --
110 2.15.1
111

  ViewVC Help
Powered by ViewVC 1.1.30