]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Bug fix. Bidding failed when a character of the end of buffer which
authorMichihiro NAKAJIMA <ggcueroad@gmail.com>
Sat, 31 Oct 2009 05:03:48 +0000 (01:03 -0400)
committerMichihiro NAKAJIMA <ggcueroad@gmail.com>
Sat, 31 Oct 2009 05:03:48 +0000 (01:03 -0400)
was checked for bidding was '\n' but not the end of file.

SVN-Revision: 1550

libarchive/archive_read_support_compression_uu.c

index 80cb2dcc7e536d601c4be9539d0ade70cc4eb481..47a32e0e6dcc4c8d754281d24a26566224482517 100644 (file)
@@ -199,7 +199,11 @@ bid_get_line(struct archive_read_filter *filter,
        int quit;
        
        quit = 0;
-       len = get_line(*b, *avail, nl);
+       if (*avail == 0) {
+               *nl = 0;
+               len = 0;
+       } else
+               len = get_line(*b, *avail, nl);
        /*
         * Read bytes more while it does not reach the end of line.
         */
@@ -243,13 +247,13 @@ uudecode_bidder_bid(struct archive_read_filter_bidder *self,
        l = 0;
        firstline = 20;
        ravail = avail;
-       while (avail) {
+       for (;;) {
                len = bid_get_line(filter, &b, &avail, &ravail, &nl);
                if (len < 0 || nl == 0)
                        return (0);/* Binary data. */
-               if (memcmp(b, "begin ", 6) == 0 && len >= 11)
+               if (memcmp(b, "begin ", 6) == 0 && len - nl >= 11)
                        l = 6;
-               else if (memcmp(b, "begin-base64 ", 13) == 0 && len >= 18)
+               else if (memcmp(b, "begin-base64 ", 13) == 0 && len - nl >= 18)
                        l = 13;
                else
                        l = 0;