Repository : ssh://git@open-mesh.org/batctl
On branch : master
commit 09dd2dc0b4945c83bd07ad4bce64062239d901fb Author: Sven Eckelmann sven.eckelmann@openmesh.com Date: Thu Nov 23 15:04:35 2017 +0100
batctl: Print dummy value when localtime failed
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 Signed-off-by: Simon Wunderlich sw@simonwunderlich.de
09dd2dc0b4945c83bd07ad4bce64062239d901fb tcpdump.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/tcpdump.c b/tcpdump.c index 4ede76b..5eb99cf 100644 --- a/tcpdump.c +++ b/tcpdump.c @@ -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; }