|
|
c480ed |
From c8e10c7f4644646194bbcb1514bbf110ec7374ad Mon Sep 17 00:00:00 2001
|
|
|
c480ed |
Message-Id: <c8e10c7f4644646194bbcb1514bbf110ec7374ad@dist-git>
|
|
|
c480ed |
From: John Ferlan <jferlan@redhat.com>
|
|
|
c480ed |
Date: Mon, 1 Jul 2019 17:06:11 +0200
|
|
|
c480ed |
Subject: [PATCH] tests: Resolve possible overrun
|
|
|
c480ed |
MIME-Version: 1.0
|
|
|
c480ed |
Content-Type: text/plain; charset=UTF-8
|
|
|
c480ed |
Content-Transfer-Encoding: 8bit
|
|
|
c480ed |
|
|
|
c480ed |
Coverity noted that each of the fmemopen called used the strlen value
|
|
|
c480ed |
in order to allocate space, but that neglected space for terminating
|
|
|
c480ed |
null string. So just add 1 to the strlen.
|
|
|
c480ed |
|
|
|
c480ed |
Signed-off-by: John Ferlan <jferlan@redhat.com>
|
|
|
c480ed |
Reviewed-by: Erik Skultety <eskultet@redhat.com>
|
|
|
c480ed |
(cherry picked from commit 7eb56dcd9ef4c21f8f4bc5e639dc4dd01e6d572a)
|
|
|
c480ed |
|
|
|
c480ed |
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1689297
|
|
|
c480ed |
|
|
|
c480ed |
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
|
c480ed |
Message-Id: <a0d52bead1b7e31bfa1c1938c7ae19fe0a7605d4.1561993099.git.phrdina@redhat.com>
|
|
|
c480ed |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
c480ed |
---
|
|
|
c480ed |
tests/vircgroupmock.c | 21 ++++++++++++---------
|
|
|
c480ed |
1 file changed, 12 insertions(+), 9 deletions(-)
|
|
|
c480ed |
|
|
|
c480ed |
diff --git a/tests/vircgroupmock.c b/tests/vircgroupmock.c
|
|
|
c480ed |
index 51861be38e..bae8304f6c 100644
|
|
|
c480ed |
--- a/tests/vircgroupmock.c
|
|
|
c480ed |
+++ b/tests/vircgroupmock.c
|
|
|
c480ed |
@@ -468,12 +468,13 @@ FILE *fopen(const char *path, const char *mode)
|
|
|
c480ed |
if (STREQ(mode, "r")) {
|
|
|
c480ed |
if (allinone)
|
|
|
c480ed |
return fmemopen((void *)procmountsallinone,
|
|
|
c480ed |
- strlen(procmountsallinone), mode);
|
|
|
c480ed |
+ strlen(procmountsallinone) + 1, mode);
|
|
|
c480ed |
else if (logind)
|
|
|
c480ed |
return fmemopen((void *)procmountslogind,
|
|
|
c480ed |
- strlen(procmountslogind), mode);
|
|
|
c480ed |
+ strlen(procmountslogind) + 1, mode);
|
|
|
c480ed |
else
|
|
|
c480ed |
- return fmemopen((void *)procmounts, strlen(procmounts), mode);
|
|
|
c480ed |
+ return fmemopen((void *)procmounts,
|
|
|
c480ed |
+ strlen(procmounts) + 1, mode);
|
|
|
c480ed |
} else {
|
|
|
c480ed |
errno = EACCES;
|
|
|
c480ed |
return NULL;
|
|
|
c480ed |
@@ -483,12 +484,13 @@ FILE *fopen(const char *path, const char *mode)
|
|
|
c480ed |
if (STREQ(mode, "r")) {
|
|
|
c480ed |
if (allinone)
|
|
|
c480ed |
return fmemopen((void *)proccgroupsallinone,
|
|
|
c480ed |
- strlen(proccgroupsallinone), mode);
|
|
|
c480ed |
+ strlen(proccgroupsallinone) + 1, mode);
|
|
|
c480ed |
else if (logind)
|
|
|
c480ed |
return fmemopen((void *)proccgroupslogind,
|
|
|
c480ed |
- strlen(proccgroupslogind), mode);
|
|
|
c480ed |
+ strlen(proccgroupslogind) + 1, mode);
|
|
|
c480ed |
else
|
|
|
c480ed |
- return fmemopen((void *)proccgroups, strlen(proccgroups), mode);
|
|
|
c480ed |
+ return fmemopen((void *)proccgroups,
|
|
|
c480ed |
+ strlen(proccgroups) + 1, mode);
|
|
|
c480ed |
} else {
|
|
|
c480ed |
errno = EACCES;
|
|
|
c480ed |
return NULL;
|
|
|
c480ed |
@@ -498,12 +500,13 @@ FILE *fopen(const char *path, const char *mode)
|
|
|
c480ed |
if (STREQ(mode, "r")) {
|
|
|
c480ed |
if (allinone)
|
|
|
c480ed |
return fmemopen((void *)procselfcgroupsallinone,
|
|
|
c480ed |
- strlen(procselfcgroupsallinone), mode);
|
|
|
c480ed |
+ strlen(procselfcgroupsallinone) + 1, mode);
|
|
|
c480ed |
else if (logind)
|
|
|
c480ed |
return fmemopen((void *)procselfcgroupslogind,
|
|
|
c480ed |
- strlen(procselfcgroupslogind), mode);
|
|
|
c480ed |
+ strlen(procselfcgroupslogind) + 1, mode);
|
|
|
c480ed |
else
|
|
|
c480ed |
- return fmemopen((void *)procselfcgroups, strlen(procselfcgroups), mode);
|
|
|
c480ed |
+ return fmemopen((void *)procselfcgroups,
|
|
|
c480ed |
+ strlen(procselfcgroups) + 1, mode);
|
|
|
c480ed |
} else {
|
|
|
c480ed |
errno = EACCES;
|
|
|
c480ed |
return NULL;
|
|
|
c480ed |
--
|
|
|
c480ed |
2.22.0
|
|
|
c480ed |
|