From aa7928b3abde861b62b67d45462bc0e2e34470b7 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Fri, 7 Dec 2012 22:32:28 +0000 Subject: [PATCH] output ethernet: do not crash if ethernet is missing Real dhcpd.leases file should always have ethernet address markup, but test data or malformed files might not have. Even if the check is 99.99% useless there are the corner cases, and crashing at them is not good. Signed-off-by: Sami Kerola --- src/output.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/output.c b/src/output.c index ae16421..9181feb 100644 --- a/src/output.c +++ b/src/output.c @@ -245,7 +245,9 @@ int output_xml(void) fputs("\n\t", outfile); fputs(ntop_ipaddr(&l->ip), outfile); fputs("\n\t", outfile); - fputs(l->ethernet, outfile); + if (l->ethernet != NULL) { + fputs(l->ethernet, outfile); + } fputs("\n\n", outfile); } @@ -366,7 +368,9 @@ int output_json(void) fputs("\n { \"ip\":\"", outfile); fputs(ntop_ipaddr(&l->ip), outfile); fputs("\", \"macaddress\":\"", outfile); - fputs(l->ethernet, outfile); + if (l->ethernet != NULL) { + fputs(l->ethernet, outfile); + } fputs("\" }", outfile); } }