summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 10692e3)
raw | patch | inline | side by side (parent: 10692e3)
author | Vincent Brillault <git@lerya.net> | |
Tue, 23 Sep 2014 20:28:52 +0000 (22:28 +0200) | ||
committer | Vincent Brillault <git@lerya.net> | |
Sat, 28 Feb 2015 06:35:42 +0000 (07:35 +0100) |
src/turbostat.c | patch | blob | history |
diff --git a/src/turbostat.c b/src/turbostat.c
index cc0be207087b389979d9dd6e69bf4179792a4753..6fa172d0b666fd1b3c612fcb3d4423215ab45257 100644 (file)
--- a/src/turbostat.c
+++ b/src/turbostat.c
ERR_CPU_ALLOC,
ERR_NOT_ROOT,
UNSUPPORTED_CPU,
+ ERR_PATH_TOO_LONG,
};
va_list args;
char path[PATH_MAX];
FILE *filep;
- int value;
+ int len, value;
va_start(args, fmt);
- vsnprintf(path, sizeof(path), fmt, args);
+ len = vsnprintf(path, sizeof(path), fmt, args);
va_end(args);
+ if (len < 0 || len >= PATH_MAX) {
+ ERROR("Turbostat plugin: path truncated: '%s'", path);
+ return -ERR_PATH_TOO_LONG;
+ }
+
filep = fopen(path, "r");
if (!filep) {
ERROR("Turbostat plugin: Failed to open '%s'", path);