Re: [xml] Don't read XML from directories.

Date view Thread view Subject view Author view

From: Igor Zlatkovic (igorz@dialup.nacamar.de)
Date: Tue Jan 23 2001 - 09:08:51 EST


Hi there.

I have a different opinion on that and would like to express it herewith.

No offense meant, Alejandro, but I think checking if you read from a
directory or not is your responsibility. Libraries like libxml (and libxml2)
should not go any deeper into the matter of checking if a passed parameter
is sane or not.

Consider that libxml2 is based on other libraries (libc, for example). I am
writing libraries atop of libxml and yet other persons over here write
libraries atop of mine. One program or another shall be based on the
highest-level library and shall sooner or later make a call which would
partly execute down in libxml2. If now every library along the way would
check the sanity of the parameter, each and every parameter would be checked
three times, four times, five times, depends on how deep from the surface
the call implementation is.

Further, consider strlen function from libc, for example. What happens if
you pass it NULL? It trashes your program, it does not return an error. A
crash is far louder an alarm, signaling a grave error in the program and
urging correction.

I am simply against the library acting as a shield before programmer's own
mistakes. What would be next? Patching strlen routine in glibc so it checks
for NULL argument before parsing the string and, if it is NULL, sends an
email to strlenwatch@localhost, sets the appropriate errno and returns -1?
Correctness and sanity of parameters any program passes to any library
function must be enforced by the program itself. No library can ever know
better what the program is about to do.

Now, if you really need to have it, putting some kind of assert in libxml2
which fires when a parameter is unsane would be a far better solution in my
eyes. Such an assert would state clearly what sort of parameters the library
expects, would have a good alarming effect if things go wrong and would be
optimised out by the compiler when making a productive release.

Igor

----
Message from the list xml@rpmfind.net
Archived at : http://xmlsoft.org/messages/
to unsubscribe: echo "unsubscribe xml" | mail  majordomo@rpmfind.net


Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Tue Jan 23 2001 - 10:44:07 EST