!37 [sync] PR-36: backport patch

From: @openeuler-sync-bot 
Reviewed-by: @HuaxinLuGitee 
Signed-off-by: @HuaxinLuGitee
This commit is contained in:
openeuler-ci-bot 2023-02-17 14:58:42 +00:00 committed by Gitee
commit 7b3d169ca8
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 60 additions and 1 deletions

View File

@ -0,0 +1,54 @@
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>
conflict:context adaptation
---
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 ) {
ssize_t length;
+ 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.32
Release: 4
Release: 5
Summary: A library for getting and setting POSIX.1e draft 15 capabilities
License: GPLv2
URL: https://sites.google.com/site/fullycapable
@ -12,6 +12,7 @@ Patch2: backport-capsh-better-error-handling-for-integer-parsing.patch
Patch3: backport-setcap-clean-up-error-handling-of-the-ns-rootid-argument.patch
Patch4: backport-If-needed-search-PATH-for-capsh-self-execution.patch
Patch5: backport-Guarantee-sufficient-memory-for-scratch-pathname.patch
Patch6: backport-getpcaps-catch-PID-parsing-errors.patch
BuildRequires: libattr-devel pam-devel perl-interpreter gcc
@ -72,6 +73,10 @@ chmod +x %{buildroot}/%{_libdir}/*.so.*
%{_mandir}/man8/*.gz
%changelog
* Thu Feb 16 2023 zhangguangzhi <zhangguangzhi3@huawei.com> - 2.32-5
- backport patch
backport getpcaps catch PID parsing errors
* Sat Jan 22 2022 yixiangzhike <yixiangzhike007@163.com> - 2.32-4
- Type:bugfix
- ID:NA