prepare busybox-power 1.19.0power3 release
[busybox-power] / debian / patches / 1.19.0-hotfixes / busybox-1.19.0-uncompress.patch
1 --- busybox-1.19.0/archival/libarchive/decompress_uncompress.c
2 +++ busybox-1.19.0-uncompress/archival/libarchive/decompress_uncompress.c
3 @@ -163,7 +163,8 @@ unpack_Z_stream(int fd_in, int fd_out)
4  
5                 if (insize < (int) (IBUFSIZ + 64) - IBUFSIZ) {
6                         rsize = safe_read(fd_in, inbuf + insize, IBUFSIZ);
7 -//error check??
8 +                       if (rsize < 0)
9 +                               bb_error_msg_and_die(bb_msg_read_error);
10                         insize += rsize;
11                 }
12  
13 @@ -195,6 +196,8 @@ unpack_Z_stream(int fd_in, int fd_out)
14  
15  
16                         if (oldcode == -1) {
17 +                               if (code >= 256)
18 +                                       bb_error_msg_and_die("corrupted data"); /* %ld", code); */
19                                 oldcode = code;
20                                 finchar = (int) oldcode;
21                                 outbuf[outpos++] = (unsigned char) finchar;
22 @@ -239,6 +242,8 @@ unpack_Z_stream(int fd_in, int fd_out)
23  
24                         /* Generate output characters in reverse order */
25                         while ((long) code >= (long) 256) {
26 +                               if (stackp <= &htabof(0))
27 +                                       bb_error_msg_and_die("corrupted data");
28                                 *--stackp = tab_suffixof(code);
29                                 code = tab_prefixof(code);
30                         }
31 @@ -263,8 +268,7 @@ unpack_Z_stream(int fd_in, int fd_out)
32                                                 }
33  
34                                                 if (outpos >= OBUFSIZ) {
35 -                                                       full_write(fd_out, outbuf, outpos);
36 -//error check??
37 +                                                       xwrite(fd_out, outbuf, outpos);
38                                                         IF_DESKTOP(total_written += outpos;)
39                                                         outpos = 0;
40                                                 }
41 @@ -292,8 +296,7 @@ unpack_Z_stream(int fd_in, int fd_out)
42         } while (rsize > 0);
43  
44         if (outpos > 0) {
45 -               full_write(fd_out, outbuf, outpos);
46 -//error check??
47 +               xwrite(fd_out, outbuf, outpos);
48                 IF_DESKTOP(total_written += outpos;)
49         }
50