diff options
author | Xiangyu Chen <xiangyu.chen@windriver.com> | 2023-04-19 13:43:35 +0800 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-04-20 11:56:06 +0100 |
commit | ef16919e98108724ede5ad5d79e3cbab1918d6d5 (patch) | |
tree | d75b32e4d7e044d7c0c0aba916b14ea64be54e2b /meta/recipes-extended/shadow/files/0001-Overhaul-valid_field.patch | |
parent | 22fc34613bb5d2a5b1713de6ff0fe1fafb4949a7 (diff) | |
download | poky-ef16919e98108724ede5ad5d79e3cbab1918d6d5.tar.gz |
shadow: backport patch to fix CVE-2023-29383
The fix of CVE-2023-29383.patch contains a bug that it rejects all
characters that are not control ones, so backup another patch named
"0001-Overhaul-valid_field.patch" from upstream to fix it.
(From OE-Core rev: c5da9027cc73484936f4f82a37c32348cee1e229)
Signed-off-by: Xiangyu Chen <xiangyu.chen@windriver.com>
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-extended/shadow/files/0001-Overhaul-valid_field.patch')
-rw-r--r-- | meta/recipes-extended/shadow/files/0001-Overhaul-valid_field.patch | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/meta/recipes-extended/shadow/files/0001-Overhaul-valid_field.patch b/meta/recipes-extended/shadow/files/0001-Overhaul-valid_field.patch new file mode 100644 index 0000000000..ac08be515b --- /dev/null +++ b/meta/recipes-extended/shadow/files/0001-Overhaul-valid_field.patch | |||
@@ -0,0 +1,65 @@ | |||
1 | From 2eaea70111f65b16d55998386e4ceb4273c19eb4 Mon Sep 17 00:00:00 2001 | ||
2 | From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= <cgzones@googlemail.com> | ||
3 | Date: Fri, 31 Mar 2023 14:46:50 +0200 | ||
4 | Subject: [PATCH] Overhaul valid_field() | ||
5 | |||
6 | e5905c4b ("Added control character check") introduced checking for | ||
7 | control characters but had the logic inverted, so it rejects all | ||
8 | characters that are not control ones. | ||
9 | |||
10 | Cast the character to `unsigned char` before passing to the character | ||
11 | checking functions to avoid UB. | ||
12 | |||
13 | Use strpbrk(3) for the illegal character test and return early. | ||
14 | |||
15 | Upstream-Status: Backport [https://github.com/shadow-maint/shadow/commit/2eaea70111f65b16d55998386e4ceb4273c19eb4] | ||
16 | |||
17 | Signed-off-by: Xiangyu Chen <xiangyu.chen@windriver.com> | ||
18 | --- | ||
19 | lib/fields.c | 24 ++++++++++-------------- | ||
20 | 1 file changed, 10 insertions(+), 14 deletions(-) | ||
21 | |||
22 | diff --git a/lib/fields.c b/lib/fields.c | ||
23 | index fb51b582..53929248 100644 | ||
24 | --- a/lib/fields.c | ||
25 | +++ b/lib/fields.c | ||
26 | @@ -37,26 +37,22 @@ int valid_field (const char *field, const char *illegal) | ||
27 | |||
28 | /* For each character of field, search if it appears in the list | ||
29 | * of illegal characters. */ | ||
30 | + if (illegal && NULL != strpbrk (field, illegal)) { | ||
31 | + return -1; | ||
32 | + } | ||
33 | + | ||
34 | + /* Search if there are non-printable or control characters */ | ||
35 | for (cp = field; '\0' != *cp; cp++) { | ||
36 | - if (strchr (illegal, *cp) != NULL) { | ||
37 | + unsigned char c = *cp; | ||
38 | + if (!isprint (c)) { | ||
39 | + err = 1; | ||
40 | + } | ||
41 | + if (iscntrl (c)) { | ||
42 | err = -1; | ||
43 | break; | ||
44 | } | ||
45 | } | ||
46 | |||
47 | - if (0 == err) { | ||
48 | - /* Search if there are non-printable or control characters */ | ||
49 | - for (cp = field; '\0' != *cp; cp++) { | ||
50 | - if (!isprint (*cp)) { | ||
51 | - err = 1; | ||
52 | - } | ||
53 | - if (!iscntrl (*cp)) { | ||
54 | - err = -1; | ||
55 | - break; | ||
56 | - } | ||
57 | - } | ||
58 | - } | ||
59 | - | ||
60 | return err; | ||
61 | } | ||
62 | |||
63 | -- | ||
64 | 2.34.1 | ||
65 | |||