changeset 109:2bedacfe1ba7 noffle

[svn] Fix header line reading buf
author bears
date Mon, 19 Jun 2000 22:56:12 +0100
parents 8eb2975c8c1a
children d23f038454d4
files ChangeLog src/database.c src/util.c
diffstat 3 files changed, 16 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Tue Jun 13 07:44:21 2000 +0100
+++ b/ChangeLog	Mon Jun 19 22:56:12 2000 +0100
@@ -2,6 +2,10 @@
 NOFFLE ChangeLog
 -------------------------------------------------------------------------------
 
+Mon Jun 19 22:43:38 BST 2000 Jim Hague <jim.hague@acm.org>
+
+ * src/util.c, src/database.c: Fix header line reading bug.
+
 Tue Jun 13 07:27:21 BST 2000 Jim Hague <jim.hague@acm.org>
 
   * src/configfile.h, src/configfile.c, src/database.c: Redo config
--- a/src/database.c	Tue Jun 13 07:44:21 2000 +0100
+++ b/src/database.c	Mon Jun 19 22:56:12 2000 +0100
@@ -1,7 +1,7 @@
 /*
   database.c
 
-  $Id: database.c 144 2000-06-13 06:36:26Z bears $
+  $Id: database.c 149 2000-06-19 21:56:12Z bears $
 
   Uses GNU gdbm library. Using Berkeley db (included in libc6) was
   cumbersome. It is based on Berkeley db 1.85, which has severe bugs
@@ -246,7 +246,6 @@
 Db_storeArt( const char *msgId, const char *artTxt )
 {
     Str line, lineEx, field, value;
-    const char *startPos;
 
     ASSERT( db.dbf );
 
@@ -268,10 +267,8 @@
     DynStr_clear( db.txt );
 
     /* Read header */
-    startPos = artTxt;
-    while ( TRUE )
+    while ( ( artTxt = Utl_getHeaderLn( lineEx, artTxt ) ) != NULL )
     {
-        artTxt = Utl_getHeaderLn( lineEx, artTxt );
         if ( lineEx[ 0 ] == '\0' )
         {
             DynStr_appLn( db.txt, lineEx );
@@ -299,8 +296,14 @@
         }
     }
 
+    if ( artTxt == NULL )
+    {
+	Log_err( "Article %s malformed: missing body", msgId );
+	return FALSE;
+    }
+
     /* Read body */
-    while ( ( artTxt = Utl_getLn( line, artTxt ) ) )
+    while ( ( artTxt = Utl_getLn( line, artTxt ) ) != NULL )
         if ( ! ( db.status & DB_NOT_DOWNLOADED ) )
             DynStr_appLn( db.txt, line );
     
--- a/src/util.c	Tue Jun 13 07:44:21 2000 +0100
+++ b/src/util.c	Mon Jun 19 22:56:12 2000 +0100
@@ -1,7 +1,7 @@
 /*
   util.c
 
-  $Id: util.c 110 2000-05-19 15:12:45Z bears $
+  $Id: util.c 149 2000-06-19 21:56:12Z bears $
 */
 
 #if HAVE_CONFIG_H
@@ -127,7 +127,7 @@
     const char * res = Utl_getLn( result, p );
 
     /* Look for followon line if this isn't a blank line. */
-    if ( res != NULL && !isspace( result[ 0 ] ) )
+    if ( res != NULL && result[ 0 ] != '\0' && ! isspace( result[ 0 ] ) )
 	for(;;)
 	{
 	    Str nextLine;
@@ -137,7 +137,7 @@
 	    nextLine[ 0 ] = '\0';
 	    res = Utl_getLn( nextLine, res );
 	    if ( res == NULL || nextLine[ 0 ] == '\0'
-		 || !isspace( nextLine[ 0 ] ) )
+		 || ! isspace( nextLine[ 0 ] ) )
 	    {
 		res = here;
 		break;