index : pacman | |
Archlinux32 fork of pacman | gitolite user |
summaryrefslogtreecommitdiff |
author | Tobias Stoeckmann <tobias@stoeckmann.org> | 2016-06-18 18:41:07 +0200 |
---|---|---|
committer | Andrew Gregory <andrew.gregory.8@gmail.com> | 2017-05-08 23:27:41 -0400 |
commit | 3218360114d0e3a3a965feb2f6fd3f4e2da8c8a0 (patch) | |
tree | 620ecf9a078da881f2e954c5f1566a87276fb5f0 /lib/libalpm | |
parent | 8abb0cbf0e76bc9e59aa58b368ca11a2f0c189f2 (diff) |
-rw-r--r-- | lib/libalpm/be_package.c | 14 |
diff --git a/lib/libalpm/be_package.c b/lib/libalpm/be_package.c index a79c0c5b..430d2aeb 100644 --- a/lib/libalpm/be_package.c +++ b/lib/libalpm/be_package.c @@ -24,6 +24,7 @@ #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> +#include <limits.h> /* libarchive */ #include <archive.h> @@ -695,22 +696,25 @@ error: return NULL; } +/* adopted limit from repo-add */ +#define MAX_SIGFILE_SIZE 16384 + static int read_sigfile(const char *sigpath, unsigned char **sig) { struct stat st; FILE *fp; - if(stat(sigpath, &st) != 0) { + if((fp = fopen(sigpath, "rb")) == NULL) { return -1; } - MALLOC(*sig, st.st_size, return -1); - - if((fp = fopen(sigpath, "rb")) == NULL) { - free(*sig); + if(fstat(fileno(fp), &st) != 0 || st.st_size > MAX_SIGFILE_SIZE) { + fclose(fp); return -1; } + MALLOC(*sig, st.st_size, fclose(fp); return -1); + if(fread(*sig, st.st_size, 1, fp) != 1) { free(*sig); fclose(fp); |