summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLukas Nykryn <lnykryn@redhat.com>2013-01-10 14:36:42 +0100
committerKay Sievers <kay@vrfy.org>2013-01-10 15:22:58 +0100
commitef2648c12793ded136eb81b2482f84027cade614 (patch)
treebcfdc19d0474293a53cf137f3079e686c69ae686 /src
parent1d010426c01044350b2b32d8b3af5d064f7dfe27 (diff)
downloadsystemd-ef2648c12793ded136eb81b2482f84027cade614.tar.gz
systemd-ef2648c12793ded136eb81b2482f84027cade614.tar.bz2
systemd-ef2648c12793ded136eb81b2482f84027cade614.zip
bootchart: make sure that every read buffer is null terminated
Diffstat (limited to 'src')
-rw-r--r--src/bootchart/log.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/bootchart/log.c b/src/bootchart/log.c
index eda001a20e..78f0cab178 100644
--- a/src/bootchart/log.c
+++ b/src/bootchart/log.c
@@ -182,8 +182,10 @@ schedstat_next:
if (e_fd) {
n = pread(e_fd, buf, sizeof(buf) - 1, 0);
- if (n > 0)
+ if (n > 0) {
+ buf[n] = '\0';
entropy_avail[sample] = atoi(buf);
+ }
}
}
@@ -256,6 +258,7 @@ schedstat_next:
close(ps->sched);
continue;
}
+ buf[s] = '\0';
if (!sscanf(buf, "%s %*s %*s", key))
continue;
@@ -337,8 +340,8 @@ schedstat_next:
if (ps->schedstat == -1)
continue;
}
-
- if (pread(ps->schedstat, buf, sizeof(buf) - 1, 0) <= 0) {
+ s = pread(ps->schedstat, buf, sizeof(buf) - 1, 0);
+ if (s <= 0) {
/* clean up our file descriptors - assume that the process exited */
close(ps->schedstat);
if (ps->sched)
@@ -347,6 +350,8 @@ schedstat_next:
// fclose(ps->smaps);
continue;
}
+ buf[s] = '\0';
+
if (!sscanf(buf, "%s %s %*s", rt, wt))
continue;
@@ -401,7 +406,8 @@ catch_rename:
if (ps->sched == -1)
continue;
}
- if (pread(ps->sched, buf, sizeof(buf) - 1, 0) <= 0) {
+ s = pread(ps->sched, buf, sizeof(buf) - 1, 0);
+ if (s <= 0) {
/* clean up file descriptors */
close(ps->sched);
if (ps->schedstat)
@@ -410,6 +416,7 @@ catch_rename:
// fclose(ps->smaps);
continue;
}
+ buf[s] = '\0';
if (!sscanf(buf, "%s %*s %*s", key))
continue;