changeset 202:027608dbd16b noffle

[svn] fixed SIGSEGV in Utl_getHeaderLn(); minor bugfix at Utl_parseNewsDate(). mliss
author mirkol
date Sun, 11 Nov 2001 03:53:07 +0000
parents 046910e478f0
children 5b23ec777ae6
files src/util.c
diffstat 1 files changed, 19 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/util.c	Thu Nov 08 20:53:54 2001 +0000
+++ b/src/util.c	Sun Nov 11 03:53:07 2001 +0000
@@ -1,7 +1,7 @@
 /*
   util.c
 
-  $Id: util.c 316 2001-10-31 11:44:53Z bears $
+  $Id: util.c 321 2001-11-11 03:53:07Z mirkol $
 */
 
 #if HAVE_CONFIG_H
@@ -124,6 +124,7 @@
 Utl_getHeaderLn( Str result, const char *p )
 {
     const char * res = Utl_getLn( result, p );
+    Bool not_too_long_header = TRUE;
 
     /* Look for followon line if this isn't a blank line. */
     if ( res != NULL && result[ 0 ] != '\0' && ! isspace( result[ 0 ] ) )
@@ -143,8 +144,20 @@
 	    }
 	    else
 	    {
-		Utl_catStr( result, "\n" );
-		Utl_catStr( result, nextLine );
+                if ( not_too_long_header &&
+                     ( MAXCHAR > ( strlen( result ) + strlen( nextLine ) + 1 ) ) )
+                {
+                    Utl_catStr( result, "\n"   );
+		    Utl_catStr( result, nextLine );
+                }
+                else
+                {
+                    Log_err( "Utl_getHeaderLn: skipped continued header: %s", nextLine );
+                    not_too_long_header = FALSE;
+                    /* Now let poor little noffle skip the header continuations. */
+                    /* We really need to up the size limit of headers much */
+                    /* higher than MAXCHAR = 2048. mliss */
+                }
 	    }
 	}
 
@@ -416,8 +429,7 @@
 
     /* GMT/UT or timezone offset */
     tzoffset = 0;
-    while ( isspace( *s ) )
-	s++;
+    s = nextNonWhiteSpace( s );
     if ( strncasecmp( s, "GMT", 3) == 0 )
 	s += 3;
     else if ( strncasecmp( s, "UT", 2 ) == 0 )
@@ -425,6 +437,8 @@
     else
     {
 	offset = (int) strtol( s, &p, 10 );
+	if ( p == s )
+	    return (time_t) -1;
 	s = p;
 	tzoffset = ( offset / 100 ) * 60 + ( offset % 100 );
     }