From: gabrielstedman Date: Sat, 25 May 2019 18:57:04 +0000 (+0100) Subject: Handle file not existing case #704 X-Git-Tag: upstream/1.9.3~2^2~35^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=729eef61a12d381f436da180329dba74b9892aa4;p=platform%2Fupstream%2Flz4.git Handle file not existing case #704 --- diff --git a/programs/lz4cli.c b/programs/lz4cli.c index c83b4cc..3619cd5 100644 --- a/programs/lz4cli.c +++ b/programs/lz4cli.c @@ -648,9 +648,16 @@ int main(int argc, const char** argv) DISPLAYLEVEL(1, "refusing to read from a console\n"); exit(1); } - /* if input==stdin and no output defined, stdout becomes default output */ - if (!strcmp(input_filename, stdinmark) && !output_filename) - output_filename = stdoutmark; + if (!strcmp(input_filename, stdinmark)) { + /* if input==stdin and no output defined, stdout becomes default output */ + if (!output_filename) output_filename = stdoutmark; + } + else{ + if (!recursive && !UTIL_isRegFile(input_filename)) { + DISPLAYLEVEL(1, "%s: is not a regular file \n", input_filename); + exit(1); + } + } /* No output filename ==> try to select one automatically (when possible) */ while ((!output_filename) && (multiple_inputs==0)) { diff --git a/tests/Makefile b/tests/Makefile index a38031a..65713ef 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -376,6 +376,7 @@ test-lz4-testmode: lz4 datagen @echo "\n ---- non-existing source ----" ! $(LZ4) file-does-not-exist ! $(LZ4) -f file-does-not-exist + ! $(LZ4) -t file-does-not-exist ! $(LZ4) -fm file1-dne file2-dne @$(RM) tmp-tlt tmp-tlt1 tmp-tlt2 tmp-tlt2.lz4