Add checks for fgets() when reading proc
If expected proc headers are missing, catch and print error.
diff --git a/ip/ip6tunnel.c b/ip/ip6tunnel.c
index f0db5aa..b08723a 100644
--- a/ip/ip6tunnel.c
+++ b/ip/ip6tunnel.c
@@ -262,8 +262,11 @@
}
/* skip two lines at the begenning of the file */
- fgets(buf, sizeof(buf), fp);
- fgets(buf, sizeof(buf), fp);
+ if (!fgets(buf, sizeof(buf), fp) ||
+ !fgets(buf, sizeof(buf), fp)) {
+ fprintf(stderr, "/proc/net/dev read error\n");
+ return -1;
+ }
while (fgets(buf, sizeof(buf), fp) != NULL) {
char name[IFNAMSIZ];