httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c...@decus.org (Rodent of Unusual Size)
Subject [PATCH] Fix for vbprintf("%s") and NULL pointers
Date Sat, 15 Feb 1997 21:35:21 GMT
    The attached patch seems to do the trick.  While it's sometimes
    reasonable for a routine to die horribly if given bogus arguments,
    vbprintf() extends printf(), so IMHO it shouldn't introduce a bug
    in the basic printf functionality it's emulating.. ?

    #ken    :-)}

Index: http_bprintf.c
===================================================================
RCS file: /usr/users/coar/myApache/repository/apache/src/http_bprintf.c,v
retrieving revision 1.7
diff -c -r1.7 http_bprintf.c
*** 1.7	1996/11/03 20:36:34
--- http_bprintf.c	1997/02/15 21:32:23
***************
*** 42,47 ****
--- 42,51 ----
      /*
       * Max size of a format specifier is 1 + 5 + 7 + 7 + 2 + 1 + slop
       */
+ #define NULL_STRING "(null)"
+     /*
+      * String displayed if given a NULL pointer.
+      */
  
  /*
   * Copy n characters from *srcPtr to *destPtr, then increment
***************
*** 277,282 ****
--- 281,289 ----
  
  		case 's':
  		    charPtrArg = va_arg(arg, char *);
+ 		    if (charPtrArg == NULL) {
+ 			charPtrArg = NULL_STRING;
+ 		    };
  		    if(precision == -1)
  			buffReqd = strlen(charPtrArg);
  		    else
***************
*** 444,449 ****
--- 451,459 ----
  		    if(fastPath)
  			{
  			buffPtr = va_arg(arg, char *);
+ 			if (buffPtr == NULL) {
+ 			    buffPtr = NULL_STRING;
+ 			};
  			buffCount = strlen(buffPtr);
  			buffLen = buffCount + 1;
  			}

Mime
View raw message