summaryrefslogtreecommitdiffstats
path: root/lib/libarchive/archive_read_open_fd.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_fd.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_fd.c')
-rw-r--r--lib/libarchive/archive_read_open_fd.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/libarchive/archive_read_open_fd.c b/lib/libarchive/archive_read_open_fd.c
index cab1f9f..e3b2527 100644
--- a/lib/libarchive/archive_read_open_fd.c
+++ b/lib/libarchive/archive_read_open_fd.c
@@ -27,12 +27,14 @@
#include "archive_platform.h"
__FBSDID("$FreeBSD$");
+#include <sys/stat.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "archive.h"
+#include "archive_private.h"
struct read_fd_data {
int fd;
@@ -63,9 +65,16 @@ archive_read_open_fd(struct archive *a, int fd, size_t block_size)
static int
file_open(struct archive *a, void *client_data)
{
- (void)client_data; /* UNUSED */
- (void)a; /* UNUSED */
+ struct read_fd_data *mine = client_data;
+ struct stat st;
+
+ if (fstat(mine->fd, &st) != 0) {
+ archive_set_error(a, errno, "Can't stat fd %d", mine->fd);
+ return (ARCHIVE_FATAL);
+ }
+ a->skip_file_dev = st.st_dev;
+ a->skip_file_ino = st.st_ino;
return (ARCHIVE_OK);
}
OpenPOWER on IntegriCloud