From: Daniel Veillard (Daniel.Veillard@imag.fr)
Date: Wed Feb 21 2001 - 15:58:51 EST
On Wed, Feb 21, 2001 at 02:44:23PM -0600, Todd Babinski wrote:
>
> I have been working with the library on WinNT for a couple of weeks now,
> seeing if it will fit the needs for a project that I am on. I've
> noticed a problem with how the errors are handled. The programmer is
> allowed to set the context and function used to handle the errors using
> the xmlSetGenericErrorFunc, and then that is supposed to be used in
> error handling from there on out. The problem I've encountered is how
> the context (xmlGenericErrorContext) gets used in the functions
> xmlParserWarning, xmlParserValidityError, and xmlParserValidityWarning.
> The context is treaded as a FILE* in these functions with the following
> code snippet (similar in all the functions):
>
> va_start(args,msg);
> vfprintf(xmlGenericErrorContext,msg, args);
> va_end(args);
>
> This works for contexts such as stderr, but in my case, the context will
> be a pointer to a GUI interpreter, and the above code causes the program
> to hang. I've changed the above code on my machine to the following to
> allow more flexibility in reporting of parser warnings and errors:
>
> char buf[8192] = {'\0'};
> ...
> va_start(args,msg);
> vsprintf(buf, msg, args);
> va_end(args);
> xmlGenericError(xmlGenericErrorContext, buf);
>
> I choose 8192 as the string length because it worked in my code, though
> I know that it could have a potential overrun for long errors. It
> shouldn't be that hard to cobble together a function that would
> dynamically allocate a long enough char* to fit the entire message
> without overruns.
Okay, I think someone told me about this problem already,
this need to be fixed. Using vsnprintf would avoid the
overrun but is not portable ... Though the man page on linux
says:
The snprintf and vsnprintf functions conform to ISO/IEC 9899:1999.
Daniel
-- Daniel Veillard | Red Hat Network http://redhat.com/products/network/ veillard@redhat.com | libxml Gnome XML toolkit http://xmlsoft.org/ http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/ ---- Message from the list xml@rpmfind.net Archived at : http://xmlsoft.org/messages/ to unsubscribe: echo "unsubscribe xml" | mail majordomo@rpmfind.net
This archive was generated by hypermail 2b29 : Wed Feb 21 2001 - 16:43:50 EST