Changeset 1585


Ignore:
Timestamp:
05/06/10 15:43:50 (3 years ago)
Author:
perry
Message:

Reinitialise and skip of Z_STREAM_END markers that might be in the middle of the stream.

(*cough corel cough*)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/ior-zlib.c

    r1521 r1585  
    107107                                (char*)DATA(io)->inbuff, 
    108108                                sizeof(DATA(io)->inbuff)); 
    109                         if (bytes_read == 0) /* EOF */ 
     109                        if (bytes_read == 0) { 
     110                                /* EOF */ 
     111                                if (DATA(io)->strm.avail_out == len) { 
     112                                        DATA(io)->err = ERR_EOF; 
     113                                        return 0; 
     114                                } 
     115                                /* Return how much data we've managed to read so far. */ 
    110116                                return len-DATA(io)->strm.avail_out; 
     117                        } 
    111118                        if (bytes_read < 0) { /* Error */ 
    112119                                /* errno should be set */ 
     
    129136                                break; 
    130137                        case Z_STREAM_END: 
    131                                 DATA(io)->err = ERR_EOF; 
     138                                /* You would think that an "EOF" on the stream would mean we'd 
     139                                 * want to pass on an EOF?  Nope.  Some tools (*cough* corel *cough*) 
     140                                 * annoyingly close and reopen the gzip stream leaving Z_STREAM_END 
     141                                 * mines for us to find. 
     142                                 */ 
     143                                inflateEnd(&DATA(io)->strm); 
     144                                inflateInit2(&DATA(io)->strm, 15 | 32); 
     145                                DATA(io)->err = ERR_OK; 
    132146                                break; 
    133147                        default: 
Note: See TracChangeset for help on using the changeset viewer.