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
This commit is contained in:
Christof Schulze 2019-08-13 19:15:51 +02:00 committed by Andreas Ziegler
parent f90b673f14
commit 33fb58bbf9
1 changed files with 2 additions and 3 deletions

View File

@ -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);