Fossil

Artifact [4be73b38]
Login

Artifact [4be73b38]

Artifact 4be73b381720dd41122992c32af5ae34414ed3e2:

Attachment "manifest_parse_fix.diff" to ticket [be56c89d] added by anonymous 2010-10-16 10:49:32.
Index: src/manifest.c
===================================================================
--- src/manifest.c
+++ src/manifest.c
@@ -199,11 +199,11 @@
 */
 int manifest_parse(Manifest *p, Blob *pContent){
   int seenHeader = 0;
   int seenZ = 0;
   int i, lineNo=0;
-  Blob line, token, a1, a2, a3, a4;
+  Blob inputline, line, token, a1, a2, a3, a4;
   char cPrevType = 0;
 
   memset(p, 0, sizeof(*p));
   memcpy(&p->content, pContent, sizeof(p->content));
   blob_zero(pContent);
@@ -211,11 +211,12 @@
 
   blob_zero(&a1);
   blob_zero(&a2);
   blob_zero(&a3);
   md5sum_init();
-  while( blob_line(pContent, &line) ){
+  while( blob_line(pContent, &inputline) ){
+    blob_copy(&line, &inputline);
     char *z = blob_buffer(&line);
     lineNo++;
     if( z[0]=='-' ){
       if( strncmp(z, "-----BEGIN PGP ", 15)!=0 ){
         goto manifest_syntax_error;
@@ -746,16 +747,18 @@
     if( p->zWikiTitle ) goto manifest_syntax_error;
     if( p->zTicketUuid ) goto manifest_syntax_error;
     p->type = CFTYPE_MANIFEST;
   }
   md5sum_init();
+  blob_reset(&line);
   return 1;
 
 manifest_syntax_error:
   /*fprintf(stderr, "Manifest error on line %i\n", lineNo);fflush(stderr);*/
   md5sum_init();
   manifest_clear(p);
+  blob_reset(&line);
   return 0;
 }
 
 /*
 ** COMMAND: test-parse-manifest