forked from pool/systemd
64 lines
2.3 KiB
Diff
64 lines
2.3 KiB
Diff
|
From e931d3f4241231e4102eda06adaf7cbfd68c6a5d Mon Sep 17 00:00:00 2001
|
||
|
From: Thomas Hindoe Paaboel Andersen <phomes@gmail.com>
|
||
|
Date: Sat, 27 Sep 2014 22:25:07 +0200
|
||
|
Subject: [PATCH] bootchart: check return of strftime
|
||
|
|
||
|
Found by coverity. Fixes: CID#996314 and #996312
|
||
|
---
|
||
|
src/bootchart/bootchart.c | 8 ++++++--
|
||
|
src/bootchart/svg.c | 5 +++--
|
||
|
2 files changed, 9 insertions(+), 4 deletions(-)
|
||
|
|
||
|
diff --git src/bootchart/bootchart.c src/bootchart/bootchart.c
|
||
|
index 8ef5ad1..366a5ab 100644
|
||
|
--- src/bootchart/bootchart.c
|
||
|
+++ 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 src/bootchart/svg.c src/bootchart/svg.c
|
||
|
index 135883f..faf377e 100644
|
||
|
--- src/bootchart/svg.c
|
||
|
+++ 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);
|
||
|
--
|
||
|
1.7.9.2
|
||
|
|