diff --git a/trunk/PKGBUILD b/trunk/PKGBUILD index 98a1992..1ebeb42 100644 --- a/trunk/PKGBUILD +++ b/trunk/PKGBUILD @@ -8,16 +8,30 @@ arch=('x86_64') url="http://foremost.sourceforge.net/" license=('custom') depends=('glibc') -makedepends=('patch') backup=(etc/foremost.conf) source=(http://foremost.sourceforge.net/pkg/$pkgname-$pkgver.tar.gz - $pkgname-makefile.patch) + foremost-config-path.patch + foremost-Makefile.patch + foremost-1.5.7-gcc10.patch + foremost-1.5.7-format-security.patch + foremost-broken-jpeg.patch + foremost-enforce-limits.patch) sha512sums=('8827c29d52496783be26374f3943eb26a154d842f34e50fb489f87b3a5045bf85f1e44d7d8d8b12b2355ba3fe4b06a0db979cc22c0f431593c5976001eb931ab' - 'eb3fc70590cafa3fb953946f6d80051ab3d976bcb3687cadb141a72dbd5bf317de68f39db7e28e27b49dd1629cab7e4c0ff5bc83c962c33026e9fe4d4ad2dc96') + '97b132d9cbd17463e3ede85e8c48cfaf1f6048c040f810e1f78c5f174251c673fe3bb0ef9c3f914a7983c3686426cbf89dd414e76c19982cf217a12a602e3b63' + '40f787ac82220aca45ff2f894cc69529526839c2db60094b2bc39067567313907e9bdeace1648e50a344d9c105598679a834cf411bae6494f8d60998b0c6218b' + '4a129e0bb97f2c8aa09d6861077e732886e1d26573cc8698abfb03b55ebcf73c7ba1fbd6de25c5a4d2ce8cd271ebf07aa277d823d54640e6922ebc72a6aaba46' + 'f9682baabcdbcf2c51ca7d9a41c95a10920123468c7bc207fb94708e0f652cf086659ae24e253abc02789d074b3a298f5d89e8ea3aff0328d92c0931500d9d61' + '78e4336a05990036f0346f200880bca9d920ae2e01121e51e98157365413590f76cfd03e9b4a5ebc34cd4f58367d9e02b32af6c732a932eff54f9a21d1b8edba' + '031494376d8e1ed340892540ba64024a4e45f3d66e8b929db4d869b2045e367580a98669b66c099a83820187d67aeb681a31de2d653cb501a1c1e594ca23bf5e') prepare() { cd "${srcdir}"/$pkgname-$pkgver - patch -Np0 -i "${srcdir}"/$pkgname-makefile.patch + patch -Np1 -i ../foremost-config-path.patch + patch -Np1 -i ../foremost-Makefile.patch + patch -Np1 -i ../foremost-1.5.7-gcc10.patch + patch -Np1 -i ../foremost-1.5.7-format-security.patch + patch -Np1 -i ../foremost-broken-jpeg.patch + patch -Np1 -i ../foremost-enforce-limits.patch } build() { diff --git a/trunk/foremost-1.5.7-format-security.patch b/trunk/foremost-1.5.7-format-security.patch new file mode 100644 index 0000000..eb9a60c --- /dev/null +++ b/trunk/foremost-1.5.7-format-security.patch @@ -0,0 +1,22 @@ +diff --git a/extract.c b/extract.c +index 3ef98a0..7c2a259 100755 +--- a/extract.c ++++ b/extract.c +@@ -2111,7 +2111,6 @@ unsigned char *extract_exe(f_state *s, u_int64_t c_offset, unsigned char *founda + int i = 0; + time_t compile_time = 0; + struct tm *ret_time; +- char comment[32]; + char ascii_time[32]; + + if (buflen < 100) +@@ -2146,8 +2145,7 @@ unsigned char *extract_exe(f_state *s, u_int64_t c_offset, unsigned char *founda + ret_time->tm_sec); + chop(ascii_time); + +- sprintf(comment, ascii_time); +- strcat(needle->comment, comment); ++ strcat(needle->comment, ascii_time); + exe_char = htos(&foundat[22], FOREMOST_LITTLE_ENDIAN); + if (exe_char & 0x2000) + { diff --git a/trunk/foremost-1.5.7-gcc10.patch b/trunk/foremost-1.5.7-gcc10.patch new file mode 100644 index 0000000..8506f59 --- /dev/null +++ b/trunk/foremost-1.5.7-gcc10.patch @@ -0,0 +1,99 @@ +diff -up foremost-1.5.7/api.c.me foremost-1.5.7/api.c +--- foremost-1.5.7/api.c.me 2020-02-06 14:15:48.218200745 +0100 ++++ foremost-1.5.7/api.c 2020-02-06 14:16:42.624853860 +0100 +@@ -20,6 +20,7 @@ int currFATblk; + int highblk = 0; + int block_list[OUR_BLK_SIZE / sizeof(int)]; + extern int errno; ++struct DIRECTORY *dirlist, *dl; + + /*Inititialize those globals used by extract_ole*/ + void init_ole() +diff -up foremost-1.5.7/extract.c.me foremost-1.5.7/extract.c +--- foremost-1.5.7/extract.c.me 2020-02-06 14:10:30.446386101 +0100 ++++ foremost-1.5.7/extract.c 2020-02-06 14:15:14.736798823 +0100 +@@ -25,6 +25,7 @@ extern char *extract_name; + extern int extract; + extern int FATblk; + extern int highblk; ++extern struct DIRECTORY *dirlist, *dl; + + /******************************************************************************** + *Function: extract_zip +diff -up foremost-1.5.7/main.h.me foremost-1.5.7/main.h +--- foremost-1.5.7/main.h.me 2020-02-06 13:48:46.923922983 +0100 ++++ foremost-1.5.7/main.h 2020-02-06 13:50:08.001849830 +0100 +@@ -292,7 +292,7 @@ char *__progname; + /* ----------------------------------------------------------------- + State Variable and Global Variables + ----------------------------------------------------------------- */ +-char wildcard; ++extern char wildcard; + typedef struct f_state + { + off_t mode; +@@ -344,7 +344,7 @@ typedef struct s_spec + int written; /*used for -a mode*/ + }s_spec; + +-s_spec search_spec[50]; /*ARRAY OF BUILTIN SEARCH TYPES*/ ++extern s_spec search_spec[50]; /*ARRAY OF BUILTIN SEARCH TYPES*/ + + typedef struct f_info { + char *file_name; +@@ -367,7 +367,7 @@ typedef struct f_info { + } f_info; + + /* Set if the user hits ctrl-c */ +-int signal_caught; ++extern int signal_caught; + + /* ----------------------------------------------------------------- + Function definitions +@@ -433,7 +433,7 @@ off_t find_file_size(FILE *f); + char *human_readable(off_t size, char *buffer); + char *units(unsigned int c); + unsigned int chop(char *buf); +-void print_search_specs(f_state *s); ++extern void print_search_specs(f_state *s); + int memwildcardcmp(const void *s1, const void *s2,size_t n,int caseSensitive); + int charactersMatch(char a, char b, int caseSensitive); + void printx(unsigned char* buf,int start, int end); +diff -up foremost-1.5.7/ole.h.me foremost-1.5.7/ole.h +--- foremost-1.5.7/ole.h.me 2020-02-06 14:08:16.524783353 +0100 ++++ foremost-1.5.7/ole.h 2020-02-06 14:10:02.954056080 +0100 +@@ -84,8 +84,8 @@ struct DIRECTORY + int s2; + int d1; + int d2; +-} +-*dirlist, *dl; ++}; ++ + + int get_dir_block(unsigned char *fd, int blknum, int buffersize); + int get_dir_info(unsigned char *src); +diff -up foremost-1.5.7/state.c.me foremost-1.5.7/state.c +--- foremost-1.5.7/state.c.me 2020-02-06 14:06:44.514684887 +0100 ++++ foremost-1.5.7/state.c 2020-02-06 14:08:03.329625827 +0100 +@@ -2,6 +2,9 @@ + + #include "main.h" + ++s_spec search_spec[50]; ++char wildcard; ++ + int initialize_state (f_state * s, int argc, char **argv) + { + char **argv_copy = argv; +diff -up foremost-1.5.7/main.c.me foremost-1.5.7/main.c +--- foremost-1.5.7/main.c.me 2020-02-06 14:20:09.918342282 +0100 ++++ foremost-1.5.7/main.c 2020-02-06 14:20:42.531733786 +0100 +@@ -15,6 +15,7 @@ + * + */ + #include "main.h" ++int signal_caught; + + #ifdef __WIN32 + diff --git a/trunk/foremost-Makefile.patch b/trunk/foremost-Makefile.patch new file mode 100644 index 0000000..9f6eaa0 --- /dev/null +++ b/trunk/foremost-Makefile.patch @@ -0,0 +1,49 @@ +diff --git a/Makefile b/Makefile +index 1a20f4f..0482ecf 100755 +--- a/Makefile ++++ b/Makefile +@@ -1,7 +1,3 @@ +- +-RAW_CC = gcc +-RAW_FLAGS = -Wall -O2 +-LINK_OPT = + VERSION = 1.5.7 + # Try to determine the host system + SYS := $(shell uname -s | tr -d "[0-9]" | tr -d "-" | tr "[A-Z]" "[a-z]") +@@ -21,12 +17,12 @@ CR_BASE = /usr/local/cross-tools/i386-mingw32msvc/bin + NAME = foremost + MAN_PAGES = $(NAME).8.gz + +-RAW_FLAGS += -DVERSION=\"$(VERSION)\" ++CFLAGS += -DVERSION=\"$(VERSION)\" + + # Where we get installed +-BIN = /usr/local/bin +-MAN = /usr/share/man/man8 +-CONF= /usr/local/etc ++BIN = $(DESTDIR)/usr/bin ++MAN = $(DESTDIR)/usr/share/man/man8 ++CONF = $(DESTDIR)/etc + # Setup for compiling and cross-compiling for Windows + # The CR_ prefix refers to cross compiling from OSX to Windows + CR_CC = $(CR_BASE)/gcc +@@ -37,9 +33,7 @@ CR_GOAL = $(NAME).exe + WINCC = $(RAW_CC) $(RAW_FLAGS) -D__WIN32 + + # Generic "how to compile C files" +-CC = $(RAW_CC) $(RAW_FLAGS) -D__UNIX +-.c.o: +- $(CC) -c $< ++CFLAGS += -D__UNIX + + + # Definitions we'll need later (and that should rarely change) +@@ -110,7 +104,7 @@ cygwin: unix + #--------------------------------------------------------------------- + + foremost: $(OBJ) +- $(CC) $(OBJ) -o $(NAME) $(LINK_OPT) ++ $(CC) $(OBJ) -o $(NAME) $(LDFLAGS) + + + #--------------------------------------------------------------------- diff --git a/trunk/foremost-broken-jpeg.patch b/trunk/foremost-broken-jpeg.patch new file mode 100644 index 0000000..97a8a9e --- /dev/null +++ b/trunk/foremost-broken-jpeg.patch @@ -0,0 +1,18 @@ +diff --git a/extract.c b/extract.c +index 7c2a259..1d015d0 100755 +--- a/extract.c ++++ b/extract.c +@@ -1869,7 +1869,12 @@ unsigned char *extract_jpeg(f_state *s, u_int64_t c_offset, unsigned char *found + if (((foundat + headersize) - buf) > buflen){ return NULL; } + + foundat += headersize; +- ++ ++ if (foundat >= (buf + buflen)) ++ { ++ return buf + needle->header_len; ++ } ++ + if (foundat[2] != (unsigned char)'\xff') + { + break; diff --git a/trunk/foremost-config-path.patch b/trunk/foremost-config-path.patch new file mode 100644 index 0000000..317d8b7 --- /dev/null +++ b/trunk/foremost-config-path.patch @@ -0,0 +1,16 @@ +Description: Look in /etc for config file by default +Origin: vendor +Forwarded: no +Author: Gürkan Sengün +Last-update: 2012-05-13 +--- a/config.c ++++ b/config.c +@@ -288,7 +288,7 @@ + #ifdef __WIN32 + set_config_file(s, "/Program Files/foremost/foremost.conf"); + #else +- set_config_file(s, "/usr/local/etc/foremost.conf"); ++ set_config_file(s, "/etc/foremost.conf"); + #endif + if ((f = fopen(get_config_file(s), "r")) == NULL) + { diff --git a/trunk/foremost-enforce-limits.patch b/trunk/foremost-enforce-limits.patch new file mode 100644 index 0000000..1685327 --- /dev/null +++ b/trunk/foremost-enforce-limits.patch @@ -0,0 +1,72 @@ +Author: Raúl Benencia +Description: Enforce limits + Enforce limits on the amount of possible patterns and the length of the config + lines in order to avoid segmentation faults and undefined behaviour. +diff --git a/config.c b/config.c +index 89fd377..c6dae3b 100755 +--- a/config.c ++++ b/config.c +@@ -187,6 +187,15 @@ int process_line(f_state *s, char *buffer, int line_number) + char **tokenarray = (char **)malloc(6 * sizeof(char[MAX_STRING_LENGTH])); + int i = 0, len = strlen(buffer); + ++ if (len == MAX_STRING_LENGTH - 1) ++ { ++ if (!(buffer[len -1] == '\n') || !(buffer[len - 2] == 0x0d && buffer[len - 1] == 0x0a)) ++ { ++ fprintf(stderr, "\nERROR: Foremost does not support lines longer than %d. Check line %d.\n", MAX_STRING_LENGTH, line_number); ++ return FALSE; ++ } ++ } ++ + /* Any line that ends with a CTRL-M (0x0d) has been processed + by a DOS editor. We will chop the CTRL-M to ignore it */ + if (buffer[len - 2] == 0x0d && buffer[len - 1] == 0x0a) +@@ -258,6 +267,12 @@ int process_line(f_state *s, char *buffer, int line_number) + + } + ++ if (s->num_builtin >= MAX_BUILTIN) ++ { ++ fprintf(stderr, "\nERROR: Reached maximum amount of entries. Line: %d. Maximum: %d\n", line_number, MAX_BUILTIN); ++ return FALSE; ++ } ++ + if (!extractSearchSpecData(s, tokenarray)) + { + fprintf(stderr, +diff --git a/main.c b/main.c +index df22350..fff5b7f 100755 +--- a/main.c ++++ b/main.c +@@ -244,7 +244,8 @@ int main(int argc, char **argv) + register_signal_handler(); + process_command_line(argc, argv, s); + +- load_config_file(s); ++ if (load_config_file(s)) ++ fatal_error(s, "Unable to load the config file"); + + if (s->num_builtin == 0) + { +diff --git a/main.h b/main.h +index 879686e..5486bb6 100755 +--- a/main.h ++++ b/main.h +@@ -198,6 +198,7 @@ char *__progname; + Program Defaults + ----------------------------------------------------------------- */ + #define MAX_STRING_LENGTH 1024 ++#define MAX_BUILTIN 50 + #define COMMENT_LENGTH 64 + + /* Modes refer to options that can be set by the user. */ +@@ -344,7 +345,7 @@ typedef struct s_spec + int written; /*used for -a mode*/ + }s_spec; + +-extern s_spec search_spec[50]; /*ARRAY OF BUILTIN SEARCH TYPES*/ ++extern s_spec search_spec[MAX_BUILTIN]; /*ARRAY OF BUILTIN SEARCH TYPES*/ + + typedef struct f_info { + char *file_name; diff --git a/trunk/foremost-makefile.patch b/trunk/foremost-makefile.patch deleted file mode 100644 index dc3683e..0000000 --- a/trunk/foremost-makefile.patch +++ /dev/null @@ -1,23 +0,0 @@ ---- Makefile.orig 2008-10-14 02:09:13.000000000 +0200 -+++ Makefile 2008-10-14 18:31:38.000000000 +0200 -@@ -26,5 +26,5 @@ - # Where we get installed --BIN = /usr/local/bin --MAN = /usr/share/man/man8 --CONF= /usr/local/etc -+BIN = $(DESTDIR)/usr/bin -+MAN = $(DESTDIR)/usr/share/man/man8 -+CONF= $(DESTDIR)/etc - # Setup for compiling and cross-compiling for Windows -diff -uNr foremost-1.4.orig/config.c foremost-1.4/config.c ---- config.c 2006-08-31 17:50:47.000000000 +0100 -+++ config.c 2006-08-31 17:51:09.000000000 +0100 -@@ -288,7 +288,7 @@ - #ifdef __WIN32 - set_config_file(s, "/Program Files/foremost/foremost.conf"); - #else -- set_config_file(s, "/usr/local/etc/foremost.conf"); -+ set_config_file(s, "/etc/foremost.conf"); - #endif - if ((f = fopen(get_config_file(s), "r")) == NULL) - {