mirror of
https://github.com/cuberite/libdeflate.git
synced 2025-09-18 08:49:39 -04:00
gzip, gunzip: require -f or -c to (de)compress symlink
This matches the behavior of GNU gzip.
This commit is contained in:
parent
e4029d1e70
commit
f100a42c02
@ -532,7 +532,7 @@ tmain(int argc, tchar *argv[])
|
||||
for (i = 0; i < argc; i++) {
|
||||
struct file_stream in;
|
||||
|
||||
ret = xopen_for_read(argv[i], &in);
|
||||
ret = xopen_for_read(argv[i], true, &in);
|
||||
if (ret != 0)
|
||||
goto out2;
|
||||
|
||||
|
@ -168,7 +168,7 @@ tmain(int argc, tchar *argv[])
|
||||
u64 size = 0;
|
||||
u64 elapsed = 0;
|
||||
|
||||
ret = xopen_for_read(argv[i], &in);
|
||||
ret = xopen_for_read(argv[i], true, &in);
|
||||
if (ret != 0)
|
||||
goto out;
|
||||
|
||||
|
@ -361,7 +361,8 @@ decompress_file(struct libdeflate_decompressor *decompressor, const tchar *path,
|
||||
}
|
||||
}
|
||||
|
||||
ret = xopen_for_read(oldpath, &in);
|
||||
ret = xopen_for_read(oldpath, options->force || options->to_stdout,
|
||||
&in);
|
||||
if (ret != 0)
|
||||
goto out_free_paths;
|
||||
|
||||
@ -432,7 +433,7 @@ compress_file(struct libdeflate_compressor *compressor, const tchar *path,
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = xopen_for_read(path, &in);
|
||||
ret = xopen_for_read(path, options->force || options->to_stdout, &in);
|
||||
if (ret != 0)
|
||||
goto out_free_newpath;
|
||||
|
||||
|
@ -196,7 +196,7 @@ quote_path(const tchar *path)
|
||||
|
||||
/* Open a file for reading, or set up standard input for reading */
|
||||
int
|
||||
xopen_for_read(const tchar *path, struct file_stream *strm)
|
||||
xopen_for_read(const tchar *path, bool symlink_ok, struct file_stream *strm)
|
||||
{
|
||||
strm->mmap_mem = NULL;
|
||||
|
||||
@ -216,7 +216,8 @@ xopen_for_read(const tchar *path, struct file_stream *strm)
|
||||
if (strm->name == NULL)
|
||||
return -1;
|
||||
|
||||
strm->fd = topen(path, O_RDONLY | O_BINARY | O_NOFOLLOW | O_SEQUENTIAL);
|
||||
strm->fd = topen(path, O_RDONLY | O_BINARY |
|
||||
(symlink_ok ? 0 : O_NOFOLLOW) | O_SEQUENTIAL);
|
||||
if (strm->fd < 0) {
|
||||
msg_errno("Can't open %"TS" for reading", strm->name);
|
||||
free(strm->name);
|
||||
|
@ -136,7 +136,8 @@ struct file_stream {
|
||||
size_t mmap_size;
|
||||
};
|
||||
|
||||
extern int xopen_for_read(const tchar *path, struct file_stream *strm);
|
||||
extern int xopen_for_read(const tchar *path, bool symlink_ok,
|
||||
struct file_stream *strm);
|
||||
extern int xopen_for_write(const tchar *path, bool force,
|
||||
struct file_stream *strm);
|
||||
extern int map_file_contents(struct file_stream *strm, u64 size);
|
||||
|
Loading…
x
Reference in New Issue
Block a user