8 Aug 2009 02:02
pcap_activate can cause pcap_geterr to return a blank string
Dustin Spicuzza <dustin <at> virtualroadside.com>
2009-08-08 00:02:35 GMT
2009-08-08 00:02:35 GMT
On linux using the latest GIT:
If you use pcap_create followed by pcap_activate when an interface
doesn't actually exist (ie, PCAP_ERROR_IFACE_NOT_UP is returned), then
pcap_geterr will return a blank value.
I noticed that the documentation does mention all the various error
codes that could be returned, and that you should call pcap_statustostr
to actually get the string if the error isn't PCAP_ERROR or PCAP_WARNING.
However, thats another decision that has to be made by the user, so it
seems like it would be nice and simple if pcap_geterr just worked no
matter what kind of error was returned. Add two lines to pcap_activate
to make pcap_geterr work as expected:
int
pcap_activate(pcap_t *p)
{
int status;
status = p->activate_op(p);
if (status >= 0)
p->activated = 1;
else if (!p->errbuf[0])
snprintf( p->errbuf, PCAP_ERRBUF_SIZE, "%s: %s", p->opt.source,
pcap_statustostr(status) );
return (status);
}
(Continue reading)
RSS Feed