From 3b8ae13c8ae03a9774def20de2600328fe2bc0d3 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Fri, 16 Jul 2004 18:18:02 +0000 Subject: [PATCH] Reading of V30 buckets was broken (for example it didn't work when a bucket 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 | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/buck2obj.c b/lib/buck2obj.c index 81d67856..1daabed9 100644 --- a/lib/buck2obj.c +++ b/lib/buck2obj.c @@ -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); - 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 { - 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) -- 2.39.2