Fix CVE-2022-40320

(cherry picked from commit 97f5d544d04f7bdf30e4ffdb288c8d52563c1dd2)
This commit is contained in:
panysh 2022-09-16 16:14:24 +08:00 committed by openeuler-sync-bot
parent 803a0f59ac
commit 7fb02eada6
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
Version: 3.3
Release: 1
Release: 2
Summary: A configuration file parser library
License: ISC
URL: https://github.com/martinh/libconfuse
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
%description
@ -30,6 +31,8 @@ Development files for %{name}.
%setup -q -n confuse-%{version}
perl -pi.orig -e 's|confuse.h|../src/confuse.h|g' tests/check_confuse.c
%patch0 -p0
%build
%configure --enable-shared --disable-static
make %{?_smp_mflags} AM_CFLAGS="-Wall -Wextra"
@ -63,5 +66,8 @@ rm -rf $RPM_BUILD_ROOT%{_datadir}/doc/confuse
%{_libdir}/pkgconfig/libconfuse.pc
%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
- package init