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 <kerolasa@iki.fi>
This commit is contained in:
Sami Kerola 2012-12-07 22:32:28 +00:00
parent fdc560bab9
commit aa7928b3ab

View file

@ -245,7 +245,9 @@ int output_xml(void)
fputs("<active_lease>\n\t<ip>", outfile);
fputs(ntop_ipaddr(&l->ip), outfile);
fputs("</ip>\n\t<macaddress>", outfile);
fputs(l->ethernet, outfile);
if (l->ethernet != NULL) {
fputs(l->ethernet, outfile);
}
fputs("</macaddress>\n</active_lease>\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);
}
}