[procps-ng/f18] Fixing ps crashes caused by insufficient buffer sizes (#917705)
Jaromír Cápík
jcapik at fedoraproject.org
Wed Mar 6 11:48:15 UTC 2013
commit c60222109dd6b6608f6f96a4404a0247229ec968
Author: Jaromir Capik <jcapik at redhat.com>
Date: Wed Mar 6 12:47:47 2013 +0100
Fixing ps crashes caused by insufficient buffer sizes (#917705)
procps-ng-3.3.3-ps-small-buffers.patch | 42 ++++++++++++++++++++++++++++++++
procps-ng.spec | 7 ++++-
2 files changed, 48 insertions(+), 1 deletions(-)
---
diff --git a/procps-ng-3.3.3-ps-small-buffers.patch b/procps-ng-3.3.3-ps-small-buffers.patch
new file mode 100644
index 0000000..2d79150
--- /dev/null
+++ b/procps-ng-3.3.3-ps-small-buffers.patch
@@ -0,0 +1,42 @@
+diff --git a/proc/readproc.c b/proc/readproc.c
+index 63dbd5c..162cbad 100644
+--- a/proc/readproc.c
++++ b/proc/readproc.c
+@@ -353,7 +353,9 @@ ENTER(0x220);
+ P->vm_swap = strtol(S,&S,10);
+ continue;
+ case_Groups:
+- { int j = strchr(S, '\n') - S; // currently lines end space + \n
++ { char *nl = strchr(S, '\n');
++ int j = nl ? (nl - S) : strlen(S);
++
+ if (j) {
+ P->supgid = xmalloc(j+1); // +1 in case space disappears
+ memcpy(P->supgid, S, j);
+@@ -735,7 +737,7 @@ int read_cmdline(char *restrict const dst, unsigned sz, unsigned pid) {
+ // room to spare.
+ static proc_t* simple_readproc(PROCTAB *restrict const PT, proc_t *restrict const p) {
+ static struct stat sb; // stat() buffer
+- static char sbuf[1024]; // buffer for stat,statm,status
++ static char sbuf[4096]; // buffer for stat,statm,status
+ char *restrict const path = PT->path;
+ unsigned flags = PT->flags;
+
+@@ -841,7 +843,7 @@ next_proc:
+ // path is a path to the task, with some room to spare.
+ static proc_t* simple_readtask(PROCTAB *restrict const PT, const proc_t *restrict const p, proc_t *restrict const t, char *restrict const path) {
+ static struct stat sb; // stat() buffer
+- static char sbuf[1024]; // buffer for stat,statm,status
++ static char sbuf[4096]; // buffer for stat,statm,status
+ unsigned flags = PT->flags;
+
+ if (unlikely(stat(path, &sb) == -1)) /* no such dirent (anymore) */
+@@ -1384,7 +1386,7 @@ proc_data_t *readproctab3 (int(*want_task)(proc_t *buf), PROCTAB *restrict const
+ * and filled out proc_t structure.
+ */
+ proc_t * get_proc_stats(pid_t pid, proc_t *p) {
+- static char path[32], sbuf[1024];
++ static char path[32], sbuf[4096];
+ struct stat statbuf;
+
+ sprintf(path, "/proc/%d", pid);
diff --git a/procps-ng.spec b/procps-ng.spec
index 121e4e5..81c82f0 100644
--- a/procps-ng.spec
+++ b/procps-ng.spec
@@ -6,7 +6,7 @@
Summary: System and process monitoring utilities
Name: procps-ng
Version: 3.3.3
-Release: 2.%{gitver}%{?dist}
+Release: 3.%{gitver}%{?dist}
License: GPLv2+ and LGPLv2+
Group: Applications/System
URL: http://gitorious.org/procps
@@ -16,6 +16,7 @@ URL: http://gitorious.org/procps
Source: %{name}-%{version}-%{gitver}.tar.xz
Patch0: procps-ng-3.3.4-selinux-spelling.patch
+Patch1: procps-ng-3.3.3-ps-small-buffers.patch
Requires(post): /sbin/ldconfig
Requires(postun): /sbin/ldconfig
@@ -72,6 +73,7 @@ System and process monitoring utilities development headers
%setup -q -n %{name}-%{version}-%{gitver}
%patch0 -p1
+%patch1 -p1
%build
echo "%{version}-%{gitver}" > .tarball-version
@@ -132,6 +134,9 @@ mkdir -p %{buildroot}%{_sysconfdir}/sysctl.d
%{_includedir}/proc
%changelog
+* Mon Mar 04 2013 Jaromir Capik <jcapik at redhat.com> - 3.3.3-3.20120807git
+- Fixing ps crashes caused by insufficient buffer sizes (#917705)
+
* Tue Sep 25 2012 Jaromir Capik <jcapik at redhat.com> - 3.3.3-2.20120807git
- SELinux spelling fixes
More information about the scm-commits
mailing list