e65fd0f0d4
- handle pipe input with the -f option (bnc#884004) * added bzip2-handle_pipe_input_with-f_option.patch OBS-URL: https://build.opensuse.org/request/show/243672 OBS-URL: https://build.opensuse.org/package/show/Archiving/bzip2?expand=0&rev=40
39 lines
1.5 KiB
Diff
39 lines
1.5 KiB
Diff
Index: bzip2-1.0.6/bzip2.c
|
|
===================================================================
|
|
--- bzip2-1.0.6.orig/bzip2.c 2010-09-11 01:04:53.000000000 +0200
|
|
+++ bzip2-1.0.6/bzip2.c 2014-07-31 16:23:22.366495659 +0200
|
|
@@ -504,6 +504,11 @@ Bool uncompressStream ( FILE *zStream, F
|
|
trycat:
|
|
if (forceOverwrite) {
|
|
rewind(zStream);
|
|
+ if (errno == EBADF || errno == ESPIPE) {
|
|
+ /* zStream is not seekable, probably a pipe,
|
|
+ so we print what we already have in the obuf buffer */
|
|
+ fwrite ( obuf, sizeof(UChar), nread, stream );
|
|
+ }
|
|
while (True) {
|
|
if (myfeof(zStream)) break;
|
|
nread = fread ( obuf, sizeof(UChar), 5000, zStream );
|
|
Index: bzip2-1.0.6/bzlib.c
|
|
===================================================================
|
|
--- bzip2-1.0.6.orig/bzlib.c 2014-07-31 14:50:19.492469544 +0200
|
|
+++ bzip2-1.0.6/bzlib.c 2014-07-31 16:25:28.271012325 +0200
|
|
@@ -1198,6 +1198,17 @@ int BZ_API(BZ2_bzRead)
|
|
|
|
ret = BZ2_bzDecompress ( &(bzf->strm) );
|
|
|
|
+ /* Unknown format. If the -f option was specified,
|
|
+ we want to write out the input data as it is.
|
|
+ However, as we can't rewind the stream in pipe,
|
|
+ we have to copy to the output buf the data
|
|
+ which were already read */
|
|
+ if (ret == BZ_DATA_ERROR_MAGIC) {
|
|
+ strncpy(buf, bzf->buf, n);
|
|
+ BZ_SETERR(BZ_DATA_ERROR_MAGIC);
|
|
+ return n;
|
|
+ }
|
|
+
|
|
if (ret != BZ_OK && ret != BZ_STREAM_END)
|
|
{ BZ_SETERR(ret); return 0; };
|
|
|