[systemd-commits] 2 commits - src/bootchart
Thomas H.P. Andersen
phomes at kemper.freedesktop.org
Sun Sep 28 05:47:04 PDT 2014
src/bootchart/bootchart.c | 8 ++++++--
src/bootchart/store.c | 6 ++++--
src/bootchart/svg.c | 5 +++--
3 files changed, 13 insertions(+), 6 deletions(-)
New commits:
commit e931d3f4241231e4102eda06adaf7cbfd68c6a5d
Author: Thomas Hindoe Paaboel Andersen <phomes at gmail.com>
Date: Sat Sep 27 22:25:07 2014 +0200
bootchart: check return of strftime
Found by coverity. Fixes: CID#996314 and #996312
diff --git a/src/bootchart/bootchart.c b/src/bootchart/bootchart.c
index 8ef5ad1..366a5ab 100644
--- a/src/bootchart/bootchart.c
+++ b/src/bootchart/bootchart.c
@@ -389,7 +389,9 @@ int main(int argc, char *argv[]) {
if (!of && (access(arg_output_path, R_OK|W_OK|X_OK) == 0)) {
t = time(NULL);
- strftime(datestr, sizeof(datestr), "%Y%m%d-%H%M", localtime(&t));
+ r = strftime(datestr, sizeof(datestr), "%Y%m%d-%H%M", localtime(&t));
+ assert_se(r > 0);
+
snprintf(output_file, PATH_MAX, "%s/bootchart-%s.svg", arg_output_path, datestr);
of = fopen(output_file, "we");
}
@@ -457,7 +459,9 @@ int main(int argc, char *argv[]) {
if (!of) {
t = time(NULL);
- strftime(datestr, sizeof(datestr), "%Y%m%d-%H%M", localtime(&t));
+ r = strftime(datestr, sizeof(datestr), "%Y%m%d-%H%M", localtime(&t));
+ assert_se(r > 0);
+
snprintf(output_file, PATH_MAX, "%s/bootchart-%s.svg", arg_output_path, datestr);
of = fopen(output_file, "we");
}
diff --git a/src/bootchart/svg.c b/src/bootchart/svg.c
index 135883f..faf377e 100644
--- a/src/bootchart/svg.c
+++ b/src/bootchart/svg.c
@@ -162,7 +162,7 @@ static void svg_title(const char *build) {
char *c;
FILE *f;
time_t t;
- int fd;
+ int fd, r;
struct utsname uts;
/* grab /proc/cmdline */
@@ -196,7 +196,8 @@ static void svg_title(const char *build) {
/* date */
t = time(NULL);
- strftime(date, sizeof(date), "%a, %d %b %Y %H:%M:%S %z", localtime(&t));
+ r = strftime(date, sizeof(date), "%a, %d %b %Y %H:%M:%S %z", localtime(&t));
+ assert_se(r > 0);
/* CPU type */
fd = openat(procfd, "cpuinfo", O_RDONLY);
commit 9bcf7507fab6e6b022ae3cc7178237e6e0a09e9a
Author: Thomas Hindoe Paaboel Andersen <phomes at gmail.com>
Date: Fri Sep 26 21:41:02 2014 +0200
bootchart: parse userinput with safe_atoi
Found by coverity. Fixes: CID#996409
diff --git a/src/bootchart/store.c b/src/bootchart/store.c
index ed683e8..3099ff1 100644
--- a/src/bootchart/store.c
+++ b/src/bootchart/store.c
@@ -192,12 +192,14 @@ vmstat_next:
m = buf;
while (m) {
+ int r;
+
if (sscanf(m, "%s %*s %*s %*s %*s %*s %*s %s %s", key, rt, wt) < 3)
goto schedstat_next;
if (strstr(key, "cpu")) {
- c = atoi((const char*)(key+3));
- if (c > MAXCPUS)
+ r = safe_atoi((const char*)(key+3), &c);
+ if (r < 0 || c > MAXCPUS)
/* Oops, we only have room for MAXCPUS data */
break;
sampledata->runtime[c] = atoll(rt);
More information about the systemd-commits
mailing list