!8 [sync] PR-4: Fix CVE-2022-40320

From: @openeuler-sync-bot 
Reviewed-by: @licihua 
Signed-off-by: @licihua
This commit is contained in:
openeuler-ci-bot 2022-09-20 02:04:59 +00:00 committed by Gitee
commit a060e967a7
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 32 additions and 1 deletions

25
CVE-2022-40320.patch Normal file
View File

@ -0,0 +1,25 @@
--- src/confuse.c
+++ src/confuse.c
@@ -1865,16 +1865,19 @@
} else {
/* ~user or ~user/path */
char *user;
+ size_t len;
file = strchr(filename, '/');
if (file == 0)
file = filename + strlen(filename);
- user = malloc(file - filename);
- if (!user)
+ len = file - filename - 1;
+ user = malloc(len + 1);
+ if (!user)
return NULL;
- strncpy(user, filename + 1, file - filename - 1);
+ strncpy(user, &filename[1], len);
+ user[len] = 0;
passwd = getpwnam(user);
free(user);
}

View File

@ -1,10 +1,11 @@
Name: libconfuse Name: libconfuse
Version: 3.3 Version: 3.3
Release: 1 Release: 2
Summary: A configuration file parser library Summary: A configuration file parser library
License: ISC License: ISC
URL: https://github.com/martinh/libconfuse URL: https://github.com/martinh/libconfuse
Source0: https://github.com/martinh/libconfuse/releases/download/v%{version}/confuse-%{version}.tar.gz Source0: https://github.com/martinh/libconfuse/releases/download/v%{version}/confuse-%{version}.tar.gz
Patch0: CVE-2022-40320.patch
BuildRequires: gcc check-devel, pkgconfig perl-interpreter make BuildRequires: gcc check-devel, pkgconfig perl-interpreter make
%description %description
@ -30,6 +31,8 @@ Development files for %{name}.
%setup -q -n confuse-%{version} %setup -q -n confuse-%{version}
perl -pi.orig -e 's|confuse.h|../src/confuse.h|g' tests/check_confuse.c perl -pi.orig -e 's|confuse.h|../src/confuse.h|g' tests/check_confuse.c
%patch0 -p0
%build %build
%configure --enable-shared --disable-static %configure --enable-shared --disable-static
make %{?_smp_mflags} AM_CFLAGS="-Wall -Wextra" make %{?_smp_mflags} AM_CFLAGS="-Wall -Wextra"
@ -63,5 +66,8 @@ rm -rf $RPM_BUILD_ROOT%{_datadir}/doc/confuse
%{_libdir}/pkgconfig/libconfuse.pc %{_libdir}/pkgconfig/libconfuse.pc
%changelog %changelog
* Fri Sep 16 2022 panyanshuang<panyanshuang@ncti-gba.cn> - 3.3-2
- Fix CVE-2022-40320
* Wed Apr 14 2021 chengzihan <chengzihan2@huawei.com> - 3.3-1 * Wed Apr 14 2021 chengzihan <chengzihan2@huawei.com> - 3.3-1
- package init - package init