From: Michihiro NAKAJIMA Date: Fri, 13 Feb 2009 19:08:14 +0000 (-0500) Subject: Do not regard a read data in which a character '\n' X-Git-Tag: v2.7.0~299 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9569cb9915e75dcf7e413f0831a1522c704a7ef5;p=thirdparty%2Flibarchive.git Do not regard a read data in which a character '\n' isn't included as last block of a mtree file or last line of a entry. A data returned by the __archive_read_ahead function isn't always includeing the character '\n' if following datas have it. SVN-Revision: 607 --- diff --git a/libarchive/archive_read_support_format_mtree.c b/libarchive/archive_read_support_format_mtree.c index 1f9c901e6..447f92268 100644 --- a/libarchive/archive_read_support_format_mtree.c +++ b/libarchive/archive_read_support_format_mtree.c @@ -1234,7 +1234,7 @@ readline(struct archive_read *a, struct mtree *mtree, char **start, ssize_t limi { ssize_t bytes_read; ssize_t total_size = 0; - ssize_t find_off; + ssize_t find_off = 0; const void *t; const char *s; void *p; @@ -1268,13 +1268,10 @@ readline(struct archive_read *a, struct mtree *mtree, char **start, ssize_t limi } memcpy(mtree->line.s + total_size, t, bytes_read); __archive_read_consume(a, bytes_read); - find_off = total_size; total_size += bytes_read; /* Null terminate. */ mtree->line.s[total_size] = '\0'; /* If we found an unescaped '\n', clean up and return. */ - if (p == NULL) - continue; for (u = mtree->line.s + find_off; *u; ++u) { if (u[0] == '\n') { *start = mtree->line.s; @@ -1296,8 +1293,12 @@ readline(struct archive_read *a, struct mtree *mtree, char **start, ssize_t limi memmove(u, u + 1, total_size - (u - mtree->line.s) + 1); --total_size; + ++u; break; } + if (u[1] == '\0') + break; } + find_off = u - mtree->line.s; } }