Interface names can be more than 7 chars long. Patch by Aleksey Fedoseev. --- vnstat-1.4/src/proc.c +++ vnstat-1.4/src/proc.c @@ -64,6 +64,7 @@ void parseproc(int newdb) { char temp[64]; + char* colon_pos; uint64_t rx, tx, rxchange=0, txchange=0, btime; /* rxchange = rx change in MB */ uint64_t krxchange=0, ktxchange=0; /* krxchange = rx change in kB */ time_t current; @@ -86,12 +87,22 @@ current=time(NULL); - /* get rx from procline, easy since it's always procline+7 */ + /* get rx position, then get it from procline */ + + colon_pos = strchr(procline, ':'); + if (colon_pos == NULL) { + if (debug) { + printf("Bad /proc/net/dev string"); + } + return; + } + + colon_pos++; #ifdef BLIMIT - rx=strtoull(procline+7, (char **)NULL, 0); + rx=strtoull(colon_pos, (char **)NULL, 0); #else - rx=strtoul(procline+7, (char **)NULL, 0); + rx=strtoul(colon_pos, (char **)NULL, 0); #endif if (newdb!=1) { @@ -116,7 +127,7 @@ /* get tx from procline, ugly hack */ - sscanf(procline+7,"%s %s %s %s %s %s %s %s %s",temp,temp,temp,temp,temp,temp,temp,temp,temp); + sscanf(colon_pos, "%s %s %s %s %s %s %s %s %s",temp,temp,temp,temp,temp,temp,temp,temp,temp); #ifdef BLIMIT tx=strtoull(temp, (char **)NULL, 0);