summaryrefslogtreecommitdiffstats
path: root/lib/libarchive/archive_read_open_file.c
diff options
context:
space:
mode:
authorkientzle <kientzle@FreeBSD.org>2004-06-27 23:36:39 +0000
committerkientzle <kientzle@FreeBSD.org>2004-06-27 23:36:39 +0000
commit4e782d8fc0c78221d9583a6bcbe7e24ce29f462f (patch)
treec82f7eabcc04f780365598726b3ee9c69a457348 /lib/libarchive/archive_read_open_file.c
parent4965bc7e55d29bec91dd841ca550f73f9b19d48a (diff)
downloadFreeBSD-src-4e782d8fc0c78221d9583a6bcbe7e24ce29f462f.zip
FreeBSD-src-4e782d8fc0c78221d9583a6bcbe7e24ce29f462f.tar.gz
Refuse to extract an entry from an archive on top of the archive being read.
(This is the converse of the "don't add an archive to itself".)
Diffstat (limited to 'lib/libarchive/archive_read_open_file.c')
-rw-r--r--lib/libarchive/archive_read_open_file.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/libarchive/archive_read_open_file.c b/lib/libarchive/archive_read_open_file.c
index fa30bbb..54e1239 100644
--- a/lib/libarchive/archive_read_open_file.c
+++ b/lib/libarchive/archive_read_open_file.c
@@ -27,6 +27,7 @@
#include "archive_platform.h"
__FBSDID("$FreeBSD$");
+#include <sys/stat.h>
#include <errno.h>
#include <fcntl.h>
#include <stdlib.h>
@@ -34,6 +35,7 @@ __FBSDID("$FreeBSD$");
#include <unistd.h>
#include "archive.h"
+#include "archive_private.h"
struct read_file_data {
int fd;
@@ -77,6 +79,7 @@ static int
file_open(struct archive *a, void *client_data)
{
struct read_file_data *mine = client_data;
+ struct stat st;
mine->buffer = malloc(mine->block_size);
if (*mine->filename != 0)
@@ -88,6 +91,14 @@ file_open(struct archive *a, void *client_data)
mine->filename);
return (ARCHIVE_FATAL);
}
+ if (fstat(mine->fd, &st) == 0) {
+ a->skip_file_dev = st.st_dev;
+ a->skip_file_ino = st.st_ino;
+ } else {
+ archive_set_error(a, errno, "Can't stat '%s'",
+ mine->filename);
+ return (ARCHIVE_FATAL);
+ }
return (0);
}
OpenPOWER on IntegriCloud