From 8a1f47917f48dbb92a1f5008c14dd49e8f7af688 Mon Sep 17 00:00:00 2001 From: Moinak Ghosh Date: Wed, 5 Feb 2014 23:43:07 +0530 Subject: [PATCH] Fix issue #18. Do not try to generate a target filename in pipe mode. --- pcompress.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/pcompress.c b/pcompress.c index 8ef3f1d..70a4f65 100644 --- a/pcompress.c +++ b/pcompress.c @@ -854,7 +854,7 @@ start_decompress(pc_ctx_t *pctx, const char *filename, char *to_filename) err = 1; goto uncomp_done; } - if (to_filename == NULL) { + if (to_filename == NULL && !pctx->pipe_mode) { char *pos; /* @@ -882,14 +882,16 @@ start_decompress(pc_ctx_t *pctx, const char *filename, char *to_filename) log_msg(LOG_WARN, 0, "Using %s for output file name.", to_filename); } } - origf = to_filename; - if ((to_filename = realpath(origf, NULL)) != NULL) { - free((void *)(to_filename)); - log_msg(LOG_ERR, 0, "File %s exists", origf); - err = 1; - goto uncomp_done; + if (!pctx->pipe_mode) { + origf = to_filename; + if ((to_filename = realpath(origf, NULL)) != NULL) { + free((void *)(to_filename)); + log_msg(LOG_ERR, 0, "File %s exists", origf); + err = 1; + goto uncomp_done; + } + to_filename = (char *)origf; } - to_filename = (char *)origf; } compressed_chunksize = chunksize + CHUNK_HDR_SZ + zlib_buf_extra(chunksize);