mirror of
https://github.com/ckolivas/lrzip.git
synced 2026-02-19 22:04:15 +01:00
Do a sanity check on infile in lrzip to ensure it's working on a file it can compress.
This commit is contained in:
parent
c1c44352e0
commit
e8824afa1b
21
main.c
21
main.c
|
|
@ -35,6 +35,12 @@
|
|||
#ifdef HAVE_SYS_RESOURCE_H
|
||||
# include <sys/resource.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_TYPES_H
|
||||
# include <sys/types.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_STAT_H
|
||||
# include <sys/stat.h>
|
||||
#endif
|
||||
#include <math.h>
|
||||
#include <termios.h>
|
||||
#ifdef HAVE_ENDIAN_H
|
||||
|
|
@ -718,8 +724,19 @@ int main(int argc, char *argv[])
|
|||
control.infile = argv[i];
|
||||
else if (!(i == 0 && STDIN))
|
||||
break;
|
||||
if (control.infile && (strcmp(control.infile, "-") == 0))
|
||||
control.flags |= FLAG_STDIN;
|
||||
if (control.infile) {
|
||||
if ((strcmp(control.infile, "-") == 0))
|
||||
control.flags |= FLAG_STDIN;
|
||||
else {
|
||||
struct stat infile_stat;
|
||||
|
||||
stat(control.infile, &infile_stat);
|
||||
if (unlikely(!S_ISREG(infile_stat.st_mode) &&
|
||||
!S_ISLNK(infile_stat.st_mode)))
|
||||
failure("lrzip only works directly on FILES.\n"
|
||||
"Use lrztar or pipe through tar for compressing directories.\n");
|
||||
}
|
||||
}
|
||||
|
||||
if (INFO && STDIN)
|
||||
failure("Will not get file info from STDIN\n");
|
||||
|
|
|
|||
Loading…
Reference in a new issue