]> mj.ucw.cz Git - libucw.git/commitdiff
Reading of V30 buckets was broken (for example it didn't work when a bucket
authorMartin Mares <mj@ucw.cz>
Fri, 16 Jul 2004 18:18:02 +0000 (18:18 +0000)
committerMartin Mares <mj@ucw.cz>
Fri, 16 Jul 2004 18:18:02 +0000 (18:18 +0000)
had only header and no body). When fixing it, I've modified it to terminate
after buck_len bytes, so the terminating NUL character is no longer needed.

lib/buck2obj.c

index 81d67856691ea9990aa60beb5d57f7387a4f74ad..1daabed91e698b39237ed71f119abde95282004e 100644 (file)
@@ -92,13 +92,18 @@ buck2obj_parse(struct buck2obj_buf *buf, uns buck_type, uns buck_len, struct fas
   else if (buck_type == BUCKET_TYPE_V30)
   {
     sh_off_t start = btell(body);
   else if (buck_type == BUCKET_TYPE_V30)
   {
     sh_off_t start = btell(body);
-    obj_read(body, o_hdr);             // end on EOF or the first empty line
+    sh_off_t end = start + buck_len;
+    byte buf[MAX_ATTR_SIZE];
+    while (btell(body) < end && bgets(body, buf, sizeof(buf)) && buf[0])
+      obj_add_attr(o_hdr, buf[0], buf+1);
     if (body_start)
       *body_start = btell(body) - start;
     else
     {
     if (body_start)
       *body_start = btell(body) - start;
     else
     {
-      obj_read(body, o_body);
-      bgetc(body);
+      while (btell(body) < end && bgets(body, buf, sizeof(buf)))
+       if (buf[0])
+         obj_add_attr(o_hdr, buf[0], buf+1);
+      ASSERT(btell(body) == end);
     }
   }
   else if (buck_type == BUCKET_TYPE_V33 || buck_type == BUCKET_TYPE_V33_LIZARD)
     }
   }
   else if (buck_type == BUCKET_TYPE_V33 || buck_type == BUCKET_TYPE_V33_LIZARD)