git.annexia.org
/
libguestfs.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Version 1.13.4.
[libguestfs.git]
/
src
/
filearch.c
diff --git
a/src/filearch.c
b/src/filearch.c
index
35a2ceb
..
0ed6425
100644
(file)
--- a/
src/filearch.c
+++ b/
src/filearch.c
@@
-26,9
+26,8
@@
#include <string.h>
#include <sys/stat.h>
#include <string.h>
#include <sys/stat.h>
-#ifdef HAVE_PCRE
#include <pcre.h>
#include <pcre.h>
-#endif
+
#ifdef HAVE_LIBMAGIC
#include <magic.h>
#endif
#ifdef HAVE_LIBMAGIC
#include <magic.h>
#endif
@@
-40,7
+39,7
@@
#include "guestfs-internal-actions.h"
#include "guestfs_protocol.h"
#include "guestfs-internal-actions.h"
#include "guestfs_protocol.h"
-#if defined(HAVE_
PCRE) && defined(HAVE_
LIBMAGIC)
+#if defined(HAVE_LIBMAGIC)
static pcre *re_file_elf;
static pcre *re_elf_ppc64;
static pcre *re_file_elf;
static pcre *re_elf_ppc64;
@@
-147,6
+146,14
@@
cpio_arch (guestfs_h *g, const char *file, const char *path)
else
method = "cat";
else
method = "cat";
+ /* Security: Refuse to download initrd if it is huge. */
+ int64_t size = guestfs_filesize (g, path);
+ if (size == -1 || size > 100000000) {
+ error (g, _("size of %s unreasonable (%" PRIi64 " bytes)"),
+ path, size);
+ goto out;
+ }
+
if (mkdtemp (dir) == NULL) {
perrorf (g, "mkdtemp");
goto out;
if (mkdtemp (dir) == NULL) {
perrorf (g, "mkdtemp");
goto out;
@@
-250,12
+257,12
@@
guestfs__file_architecture (guestfs_h *g, const char *path)
return ret; /* caller frees */
}
return ret; /* caller frees */
}
-#else /* no
PCRE or
libmagic at compile time */
+#else /* no libmagic at compile time */
/* XXX Should be an optgroup. */
#define NOT_IMPL(r) \
/* XXX Should be an optgroup. */
#define NOT_IMPL(r) \
- error (g, _("file-architecture API not available since this version of libguestfs was compiled without
PCRE or libmagic libraries
")); \
+ error (g, _("file-architecture API not available since this version of libguestfs was compiled without
the libmagic library
")); \
return r
char *
return r
char *
@@
-264,4
+271,4
@@
guestfs__file_architecture (guestfs_h *g, const char *path)
NOT_IMPL(NULL);
}
NOT_IMPL(NULL);
}
-#endif /* no
PCRE or
libmagic at compile time */
+#endif /* no libmagic at compile time */