Nmap Development mailing list archives

Consolidating fatal() and pfatal() and error(), oh my!


From: Brandon Enright <bmenrigh () ucsd edu>
Date: Fri, 29 Aug 2008 02:10:28 +0000

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hey all,

I have a few additions and changes I'd like to make to Nmap's error
handling routines to aid in debugging.  When I started to really look
into things though I realized that we have several places where Nmap
could terminate on error.

In Nbase we have:
static void fatal(char *fmt, ...)

In Nsock we have:
void fatal(char *fmt, ...)
void pfatal(char *fmt, ...)
void gh_perror(char *err, ...)

In Nmap we have:
void fatal(const char *fmt, ...)
void pfatal(const char *err, ...)
void gh_perror(const char *err, ...)
void error(const char *fmt, ...)

That's a pretty decent amount of redundant code.  Especially since
gh_perror() is a copy and paste of pfatal() who's exit() has been
replaced with a return.  I should point out though that the Nmap
version of these routines have the ability to log various outputs if
o.log_errors is set.  They are functionally equivalent in all other
regards.

I'd like to consolidate the error handling code but so far haven't come
up with an elegant solution for tackling the problem.  The nicest thing
would be to take all of the routines (except maybe error()) and move
them to Nbase.  We could also share most of the implementation of
pfatal() and gh_perror().  The trouble with this move is that we
lose the additional logging features of the Nmap error routines.

I think that logging a fatal() error isn't that big of a deal.  Nbase
and Nsock already can't log them.  By moving all but error() to Nbase we
can retain logging of all the generic errors and have only the fatal
calls go to STDERR.

I'm sure there are a lot of other options though so I'd like any
comments or insight before I go hacking away at the code any more than
I already have.

Brandon

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)

iEYEARECAAYFAki3WpoACgkQqaGPzAsl94JN2gCfbwkTVw+DzcraIXMSQOFANByv
15gAoIFaby0LCRkFA9RkYj8fbyjVFd84
=+Wzk
-----END PGP SIGNATURE-----

_______________________________________________
Sent through the nmap-dev mailing list
http://cgi.insecure.org/mailman/listinfo/nmap-dev
Archived at http://SecLists.Org


Current thread: