backport upstream patch

Signed-off-by: yixiangzhike <yixiangzhike007@163.com>
(cherry picked from commit 7f70991e3a85849ae08b98cb15ead82709746290)
This commit is contained in:
yixiangzhike 2022-11-01 11:04:38 +08:00 committed by openeuler-sync-bot
parent fe1c5dd18d
commit 984df183d4
2 changed files with 57 additions and 1 deletions

View File

@ -0,0 +1,52 @@
From fc804acc078ef03e2c5b3a233f118a537f260ccd Mon Sep 17 00:00:00 2001
From: Jakub Wilk <jwilk@jwilk.net>
Date: Thu, 1 Sep 2022 22:23:19 +0200
Subject: [PATCH] getpcaps: catch PID parsing errors.
Signed-off-by: Jakub Wilk <jwilk@jwilk.net>
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
---
progs/getpcaps.c | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/progs/getpcaps.c b/progs/getpcaps.c
index 8fce0a3..1e914b2 100644
--- a/progs/getpcaps.c
+++ b/progs/getpcaps.c
@@ -39,7 +39,9 @@ int main(int argc, char **argv)
}
for ( ++argv; --argc > 0; ++argv ) {
+ long lpid;
int pid;
+ char *endarg;
cap_t cap_d;
if (!strcmp(argv[0], "--help") || !strcmp(argv[0], "--usage") ||
@@ -62,7 +64,22 @@ int main(int argc, char **argv)
continue;
}
- pid = atoi(argv[0]);
+ errno = 0;
+ lpid = strtol(argv[0], &endarg, 10);
+ if (*endarg != '\0') {
+ errno = EINVAL;
+ }
+ if (errno == 0) {
+ if (lpid < 0 || pid != (pid_t) pid)
+ errno = EOVERFLOW;
+ }
+ if (errno != 0) {
+ fprintf(stderr, "Cannot parse pid %s (%s)\n",
+ argv[0], strerror(errno));
+ retval = 1;
+ continue;
+ }
+ pid = lpid;
cap_d = cap_get_pid(pid);
if (cap_d == NULL) {
--
2.27.0

View File

@ -1,6 +1,6 @@
Name: libcap
Version: 2.61
Release: 3
Release: 4
Summary: A library for getting and setting POSIX.1e draft 15 capabilities
License: GPLv2
URL: https://sites.google.com/site/fullycapable
@ -10,6 +10,7 @@ Patch0: libcap-buildflags.patch
Patch1: Fix-syntax-error-in-DEBUG-protected-setcap.c-code.patch
Patch2: backport-psx-free-allocated-memory-at-exit.patch
Patch3: backport-Avoid-a-deadlock-in-forked-psx-thread-exit.patch
Patch4: backport-getpcaps-catch-PID-parsing-errors.patch
BuildRequires: libattr-devel pam-devel perl-interpreter gcc
@ -73,6 +74,9 @@ chmod +x %{buildroot}/%{_libdir}/*.so.*
%{_mandir}/man8/*.gz
%changelog
* Tue Nov 1 2022 yixiangzhike <yixiangzhike007@163.com> - 2.61-4
- backport upstream patch
* Wed Oct 12 2022 yixiangzhike <yixiangzhike007@163.com> - 2.61-3
- backport upstream patches