From 33fb58bbf9b660dbb86c50ce5ff347e7941b8b08 Mon Sep 17 00:00:00 2001 From: Christof Schulze Date: Tue, 13 Aug 2019 19:15:51 +0200 Subject: [PATCH] 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 --- package/gluon-mesh-babel/src/respondd.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/package/gluon-mesh-babel/src/respondd.c b/package/gluon-mesh-babel/src/respondd.c index 29f20ccf..d82ce6af 100644 --- a/package/gluon-mesh-babel/src/respondd.c +++ b/package/gluon-mesh-babel/src/respondd.c @@ -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);