comparison src/util.c @ 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 24d4cd032da5
children eb2589384836
comparison
equal deleted inserted replaced
201:046910e478f0 202:027608dbd16b
1 /* 1 /*
2 util.c 2 util.c
3 3
4 $Id: util.c 316 2001-10-31 11:44:53Z bears $ 4 $Id: util.c 321 2001-11-11 03:53:07Z mirkol $
5 */ 5 */
6 6
7 #if HAVE_CONFIG_H 7 #if HAVE_CONFIG_H
8 #include <config.h> 8 #include <config.h>
9 #endif 9 #endif
122 122
123 const char * 123 const char *
124 Utl_getHeaderLn( Str result, const char *p ) 124 Utl_getHeaderLn( Str result, const char *p )
125 { 125 {
126 const char * res = Utl_getLn( result, p ); 126 const char * res = Utl_getLn( result, p );
127 Bool not_too_long_header = TRUE;
127 128
128 /* Look for followon line if this isn't a blank line. */ 129 /* Look for followon line if this isn't a blank line. */
129 if ( res != NULL && result[ 0 ] != '\0' && ! isspace( result[ 0 ] ) ) 130 if ( res != NULL && result[ 0 ] != '\0' && ! isspace( result[ 0 ] ) )
130 for(;;) 131 for(;;)
131 { 132 {
141 res = here; 142 res = here;
142 break; 143 break;
143 } 144 }
144 else 145 else
145 { 146 {
146 Utl_catStr( result, "\n" ); 147 if ( not_too_long_header &&
147 Utl_catStr( result, nextLine ); 148 ( MAXCHAR > ( strlen( result ) + strlen( nextLine ) + 1 ) ) )
149 {
150 Utl_catStr( result, "\n" );
151 Utl_catStr( result, nextLine );
152 }
153 else
154 {
155 Log_err( "Utl_getHeaderLn: skipped continued header: %s", nextLine );
156 not_too_long_header = FALSE;
157 /* Now let poor little noffle skip the header continuations. */
158 /* We really need to up the size limit of headers much */
159 /* higher than MAXCHAR = 2048. mliss */
160 }
148 } 161 }
149 } 162 }
150 163
151 return res; 164 return res;
152 } 165 }
414 s = p; 427 s = p;
415 } 428 }
416 429
417 /* GMT/UT or timezone offset */ 430 /* GMT/UT or timezone offset */
418 tzoffset = 0; 431 tzoffset = 0;
419 while ( isspace( *s ) ) 432 s = nextNonWhiteSpace( s );
420 s++;
421 if ( strncasecmp( s, "GMT", 3) == 0 ) 433 if ( strncasecmp( s, "GMT", 3) == 0 )
422 s += 3; 434 s += 3;
423 else if ( strncasecmp( s, "UT", 2 ) == 0 ) 435 else if ( strncasecmp( s, "UT", 2 ) == 0 )
424 s += 2; 436 s += 2;
425 else 437 else
426 { 438 {
427 offset = (int) strtol( s, &p, 10 ); 439 offset = (int) strtol( s, &p, 10 );
440 if ( p == s )
441 return (time_t) -1;
428 s = p; 442 s = p;
429 tzoffset = ( offset / 100 ) * 60 + ( offset % 100 ); 443 tzoffset = ( offset / 100 ) * 60 + ( offset % 100 );
430 } 444 }
431 445
432 /* Check for following junk */ 446 /* Check for following junk */