Skip to content
Snippets Groups Projects
Commit 33fb58bb authored by Christof Schulze's avatar Christof Schulze Committed by Andreas Ziegler
Browse files

gluon-mesh-babel: getnumber() allocate sufficient memory including \0 byte

increase size of path by 1 to be able to fit the full path including trailing \0 byte into array
parent f90b673f
No related branches found
No related tags found
No related merge requests found
......@@ -388,10 +388,9 @@ static struct json_object * respondd_provider_nodeinfo(void) {
static uint64_t getnumber(const char *ifname, const char *stat) {
const char *format = "/sys/class/net/%s/statistics/%s";
char path[strlen(format) + strlen(ifname) + strlen(stat)];
char path[strlen(format) + strlen(ifname) + strlen(stat) + 1];
snprintf(path, sizeof(path), format, ifname, stat);
if (! access(path, F_OK))
{
if (! access(path, F_OK)) {
char *line=gluonutil_read_line(path);
long long i = atoll(line);
free(line);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment