aboutsummaryrefslogtreecommitdiff
path: root/archival
diff options
context:
space:
mode:
Diffstat (limited to 'archival')
-rw-r--r--archival/libunarchive/decompress_unzip.c18
-rw-r--r--archival/libunarchive/unzip.c18
2 files changed, 34 insertions, 2 deletions
diff --git a/archival/libunarchive/decompress_unzip.c b/archival/libunarchive/decompress_unzip.c
index 9f6ed2ebe..cde16d067 100644
--- a/archival/libunarchive/decompress_unzip.c
+++ b/archival/libunarchive/decompress_unzip.c
@@ -65,8 +65,13 @@ static char *license_msg[] = {
65#include <signal.h> 65#include <signal.h>
66#include <stdlib.h> 66#include <stdlib.h>
67#include <string.h> 67#include <string.h>
68#include "config.h"
68#include "libbb.h" 69#include "libbb.h"
69 70
71#ifdef CONFIG_FEATURE_UNCOMPRESS
72int uncompress ( FILE *in, FILE *out );
73#endif
74
70static FILE *in_file, *out_file; 75static FILE *in_file, *out_file;
71 76
72/* these are freed by gz_close */ 77/* these are freed by gz_close */
@@ -911,6 +916,7 @@ extern int unzip(FILE *l_in_file, FILE *l_out_file)
911 unsigned char flags; /* compression flags */ 916 unsigned char flags; /* compression flags */
912 typedef void (*sig_type) (int); 917 typedef void (*sig_type) (int);
913 unsigned short i; 918 unsigned short i;
919 unsigned char magic [2];
914 920
915 if (signal(SIGINT, SIG_IGN) != SIG_IGN) { 921 if (signal(SIGINT, SIG_IGN) != SIG_IGN) {
916 (void) signal(SIGINT, (sig_type) abort_gzip); 922 (void) signal(SIGINT, (sig_type) abort_gzip);
@@ -926,8 +932,18 @@ extern int unzip(FILE *l_in_file, FILE *l_out_file)
926 } 932 }
927#endif 933#endif
928 934
935 magic [0] = fgetc(l_in_file);
936 magic [1] = fgetc(l_in_file);
937
938#ifdef CONFIG_FEATURE_UNCOMPRESS
939 /* Magic header for compress files, 1F 9d = \037\235 */
940 if (( magic [0] == 0x1F ) && ( magic [1] == 0x9d)) {
941 return uncompress ( l_in_file, l_out_file );
942 }
943#endif
944
929 /* Magic header for gzip files, 1F 8B = \037\213 */ 945 /* Magic header for gzip files, 1F 8B = \037\213 */
930 if ((fgetc(l_in_file) != 0x1F) || (fgetc(l_in_file) != 0x8b)) { 946 if (( magic [0] != 0x1F ) || ( magic [1] != 0x8b)) {
931 error_msg("Invalid gzip magic"); 947 error_msg("Invalid gzip magic");
932 return EXIT_FAILURE; 948 return EXIT_FAILURE;
933 } 949 }
diff --git a/archival/libunarchive/unzip.c b/archival/libunarchive/unzip.c
index 9f6ed2ebe..cde16d067 100644
--- a/archival/libunarchive/unzip.c
+++ b/archival/libunarchive/unzip.c
@@ -65,8 +65,13 @@ static char *license_msg[] = {
65#include <signal.h> 65#include <signal.h>
66#include <stdlib.h> 66#include <stdlib.h>
67#include <string.h> 67#include <string.h>
68#include "config.h"
68#include "libbb.h" 69#include "libbb.h"
69 70
71#ifdef CONFIG_FEATURE_UNCOMPRESS
72int uncompress ( FILE *in, FILE *out );
73#endif
74
70static FILE *in_file, *out_file; 75static FILE *in_file, *out_file;
71 76
72/* these are freed by gz_close */ 77/* these are freed by gz_close */
@@ -911,6 +916,7 @@ extern int unzip(FILE *l_in_file, FILE *l_out_file)
911 unsigned char flags; /* compression flags */ 916 unsigned char flags; /* compression flags */
912 typedef void (*sig_type) (int); 917 typedef void (*sig_type) (int);
913 unsigned short i; 918 unsigned short i;
919 unsigned char magic [2];
914 920
915 if (signal(SIGINT, SIG_IGN) != SIG_IGN) { 921 if (signal(SIGINT, SIG_IGN) != SIG_IGN) {
916 (void) signal(SIGINT, (sig_type) abort_gzip); 922 (void) signal(SIGINT, (sig_type) abort_gzip);
@@ -926,8 +932,18 @@ extern int unzip(FILE *l_in_file, FILE *l_out_file)
926 } 932 }
927#endif 933#endif
928 934
935 magic [0] = fgetc(l_in_file);
936 magic [1] = fgetc(l_in_file);
937
938#ifdef CONFIG_FEATURE_UNCOMPRESS
939 /* Magic header for compress files, 1F 9d = \037\235 */
940 if (( magic [0] == 0x1F ) && ( magic [1] == 0x9d)) {
941 return uncompress ( l_in_file, l_out_file );
942 }
943#endif
944
929 /* Magic header for gzip files, 1F 8B = \037\213 */ 945 /* Magic header for gzip files, 1F 8B = \037\213 */
930 if ((fgetc(l_in_file) != 0x1F) || (fgetc(l_in_file) != 0x8b)) { 946 if (( magic [0] != 0x1F ) || ( magic [1] != 0x8b)) {
931 error_msg("Invalid gzip magic"); 947 error_msg("Invalid gzip magic");
932 return EXIT_FAILURE; 948 return EXIT_FAILURE;
933 } 949 }