diff options
author | Mikko Rapeli <mikko.rapeli@iki.fi> | 2012-09-26 16:12:30 +0200 |
---|---|---|
committer | Chris E Ferron <chris.e.ferron@linux.intel.com> | 2012-09-26 10:12:57 -0700 |
commit | 72ff7dfe7222fddf784bc866bfe7f1ec226e407d (patch) | |
tree | 9467f2ddef2abdd891692bbb7f98db959928375e | |
parent | d008c983b8f176cb62e0825943dec968aaf04090 (diff) | |
download | powertop-2.0-v2-72ff7dfe7222fddf784bc866bfe7f1ec226e407d.tar.gz |
Fix string null termination and SIGABRT from glibc
According to http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=682388
the string is not null terminated when too much data is read.
This patch fixes the crashes on my system.
-rw-r--r-- | src/process/process.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/process/process.cpp b/src/process/process.cpp index 71f81b6..34dc68d 100644 --- a/src/process/process.cpp +++ b/src/process/process.cpp @@ -86,7 +86,7 @@ static void cmdline_to_string(char *str) process::process(const char *_comm, int _pid, int _tid) : power_consumer() { - char line[4096]; + char line[4097]; ifstream file; strcpy(comm, _comm); @@ -103,6 +103,7 @@ process::process(const char *_comm, int _pid, int _tid) : power_consumer() file.open(line); while (file) { file.getline(line, 4096); + line[4096] = '\0'; if (strstr(line, "Tgid")) { char *c; c = strchr(line, ':'); |