]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Do not regard a read data in which a character '\n'
authorMichihiro NAKAJIMA <ggcueroad@gmail.com>
Fri, 13 Feb 2009 19:08:14 +0000 (14:08 -0500)
committerMichihiro NAKAJIMA <ggcueroad@gmail.com>
Fri, 13 Feb 2009 19:08:14 +0000 (14:08 -0500)
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

libarchive/archive_read_support_format_mtree.c

index 1f9c901e6d771efae93e7b16a27ac93878cc7c7e..447f9226808b2e83aea0228bd94aedad4407c5bf 100644 (file)
@@ -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;
        }
 }