[01/10] batctl: Print dummy value when localtime failed
Commit Message
localtime can return NULL when the local time could not be calculated.
Accessing this NULL pointer is not allowed.
Fixes: 05f27bfcd302 ("add arp packets , change output")
Signed-off-by: Sven Eckelmann <sven.eckelmann@openmesh.com>
---
tcpdump.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
@@ -104,7 +104,11 @@ static int print_time(void)
gettimeofday(&tv, NULL);
tm = localtime(&tv.tv_sec);
- printf("%02d:%02d:%02d.%06ld ", tm->tm_hour, tm->tm_min, tm->tm_sec, tv.tv_usec);
+ if (tm)
+ printf("%02d:%02d:%02d.%06ld ", tm->tm_hour, tm->tm_min, tm->tm_sec, tv.tv_usec);
+ else
+ printf("00:00:00.000000 ");
+
return 1;
}