[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [xml] Patches to 2.3.4



On Wed, Mar 21, 2001 at 01:41:55PM -0500, Daniel Veillard wrote:
> On Wed, Mar 21, 2001 at 11:58:56AM -0600, xml thewrittenword com wrote:
> > 1. On Solaris 2.5.1 and IRIX 6.2, snprintf is *not* available. So,
> >    I copied in the snprintf.c from the Samba distribution and
> >    added an autoconf test to compile and link it into libxml2.
> >    If we do not link snprintf into libxml2, then *every* program
> >    that links against libxml2 will need snprintf.c compiled into
> >    it (like xmllint).
> 
>   Hum,  I don't know if I should take this patch, currently
> what libxml does is that if the feature is not available it doesn't
> use it. I.e. when snprintf is not there it uses sprintf. Obvious goal
> is to get the people who ship those broken OSes to fix or die by
> obsolescence by proven track of not having the minimal routines for
> secure programming.

The problem is that error.c uses vsnprintf with NO #ifdef wrapper.
And, if someone doesn't have snprintf, they definitely don't have
vsnprintf.

>   If you try to circumvent it the way you suggest then all your
> binaries ends up having that duplicated code which should be shared
> in the libc.
>   Last but not least if there is a bug in this code there is no
> simple way to fix it, you need checking and fixes on all the
> applications.
> 
>   So on theoretical grounds I'm inclined to not add the patch.
> Practically this may be better to have all platforms reuse those
> 800 lines of code than having #ifdef #else #endif scattered around
> the places where I need snprintf and vsnfprintf.
> 
>   I will need to think a bit more about it, feedback welcome.

Makes sense. How about the patch below?

-- 
albert chin (china thewrittenword com)

-- snip snip
--- error.c.orig	Wed Mar 21 09:35:39 2001
+++ error.c	Wed Mar 21 14:02:32 2001
@@ -160,10 +160,14 @@
     size = 100;
     length = 0;
 
-    while (1) {                       // From the man page for vsnprintf ....
+    while (1) {                       /* From the man page for vsnprintf .. */
 	left = size - length;
 		    /* Try to print in the allocated space. */
+#ifdef HAVE_VSNPRINTF
 	chars = vsnprintf(str + length, left, msg, args);
+#else
+	chars = vsprintf(str + length, msg, args);
+#endif
 			  /* If that worked, we're done. */
 	if ((chars > -1) && (chars < left ))
 	    break;
--- configure.in.orig	Mon Mar 19 03:08:55 2001
+++ configure.in	Wed Mar 21 14:03:09 2001
@@ -100,7 +100,7 @@
 
 dnl Checks for library functions.
 AC_FUNC_STRFTIME
-AC_CHECK_FUNCS(strdup strndup strerror snprintf)
+AC_CHECK_FUNCS(strdup strndup strerror snprintf vsnprintf)
 AC_CHECK_FUNCS(finite isnand fp_class class fpclass)
 AC_CHECK_FUNCS(strftime localtime)
 AC_CHECK_FUNCS(stat _stat)
--- config.h.in.orig	Wed Mar 21 14:04:59 2001
+++ config.h.in	Wed Mar 21 14:05:08 2001
@@ -55,6 +55,9 @@
 /* Define if you have the strndup function.  */
 #undef HAVE_STRNDUP
 
+/* Define if you have the vsnprintf function.  */
+#undef HAVE_VSNPRINTF
+
 /* Define if you have the <arpa/inet.h> header file.  */
 #undef HAVE_ARPA_INET_H
 




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]