Mercurial > noffle
diff src/database.c @ 109:2bedacfe1ba7 noffle
[svn] Fix header line reading buf
author | bears |
---|---|
date | Mon, 19 Jun 2000 22:56:12 +0100 |
parents | 1a54e1702ea2 |
children | 3c71e28c8eef |
line wrap: on
line diff
--- 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 );