diff options
Diffstat (limited to 'archival')
-rw-r--r-- | archival/gunzip.c | 28 | ||||
-rw-r--r-- | archival/tar.c | 3 |
2 files changed, 24 insertions, 7 deletions
diff --git a/archival/gunzip.c b/archival/gunzip.c index fddcc7653..db7fa1dfe 100644 --- a/archival/gunzip.c +++ b/archival/gunzip.c | |||
@@ -3,6 +3,9 @@ | |||
3 | */ | 3 | */ |
4 | 4 | ||
5 | #include "internal.h" | 5 | #include "internal.h" |
6 | #define bb_need_name_too_long | ||
7 | #define BB_DECLARE_EXTERN | ||
8 | #include "messages.c" | ||
6 | 9 | ||
7 | static const char gunzip_usage[] = | 10 | static const char gunzip_usage[] = |
8 | "gunzip [OPTION]... FILE\n\n" | 11 | "gunzip [OPTION]... FILE\n\n" |
@@ -64,6 +67,7 @@ static char *license_msg[] = { | |||
64 | #include <signal.h> | 67 | #include <signal.h> |
65 | #include <sys/stat.h> | 68 | #include <sys/stat.h> |
66 | #include <errno.h> | 69 | #include <errno.h> |
70 | #include <sys/param.h> /* for PATH_MAX */ | ||
67 | 71 | ||
68 | /* #include "tailor.h" */ | 72 | /* #include "tailor.h" */ |
69 | 73 | ||
@@ -627,8 +631,12 @@ typedef RETSIGTYPE (*sig_type) OF((int)); | |||
627 | #endif | 631 | #endif |
628 | #define RW_USER (S_IRUSR | S_IWUSR) /* creation mode for open() */ | 632 | #define RW_USER (S_IRUSR | S_IWUSR) /* creation mode for open() */ |
629 | 633 | ||
630 | #ifndef MAX_PATH_LEN | 634 | #ifndef MAX_PATH_LEN /* max pathname length */ |
631 | # define MAX_PATH_LEN 1024 /* max pathname length */ | 635 | # ifdef PATH_MAX |
636 | # define MAX_PATH_LEN PATH_MAX | ||
637 | # else | ||
638 | # define MAX_PATH_LEN 1024 | ||
639 | # endif | ||
632 | #endif | 640 | #endif |
633 | 641 | ||
634 | #ifndef SEEK_END | 642 | #ifndef SEEK_END |
@@ -696,8 +704,8 @@ int gunzip_main (int argc, char** argv) | |||
696 | int delInputFile=0; | 704 | int delInputFile=0; |
697 | struct stat statBuf; | 705 | struct stat statBuf; |
698 | char* delFileName; | 706 | char* delFileName; |
699 | char ifname[MAX_PATH_LEN]; /* input file name */ | 707 | char ifname[MAX_PATH_LEN + 1]; /* input file name */ |
700 | char ofname[MAX_PATH_LEN]; /* output file name */ | 708 | char ofname[MAX_PATH_LEN + 1]; /* output file name */ |
701 | 709 | ||
702 | if (argc==1) | 710 | if (argc==1) |
703 | usage(gunzip_usage); | 711 | usage(gunzip_usage); |
@@ -764,7 +772,11 @@ int gunzip_main (int argc, char** argv) | |||
764 | /* Open up the input file */ | 772 | /* Open up the input file */ |
765 | if (*argv=='\0') | 773 | if (*argv=='\0') |
766 | usage(gunzip_usage); | 774 | usage(gunzip_usage); |
767 | strncpy(ifname, *argv, MAX_PATH_LEN); | 775 | if (strlen(*argv) > MAX_PATH_LEN) { |
776 | fprintf(stderr, name_too_long, "gunzip"); | ||
777 | do_exit(WARNING); | ||
778 | } | ||
779 | strcpy(ifname, *argv); | ||
768 | 780 | ||
769 | /* Open input fille */ | 781 | /* Open input fille */ |
770 | inFileNum=open( ifname, O_RDONLY); | 782 | inFileNum=open( ifname, O_RDONLY); |
@@ -799,7 +811,11 @@ int gunzip_main (int argc, char** argv) | |||
799 | char* pos; | 811 | char* pos; |
800 | 812 | ||
801 | /* And get to work */ | 813 | /* And get to work */ |
802 | strncpy(ofname, ifname, MAX_PATH_LEN-4); | 814 | if (strlen(ifname) > MAX_PATH_LEN - 4) { |
815 | fprintf(stderr, name_too_long, "gunzip"); | ||
816 | do_exit(WARNING); | ||
817 | } | ||
818 | strcpy(ofname, ifname); | ||
803 | pos=strstr(ofname, ".gz"); | 819 | pos=strstr(ofname, ".gz"); |
804 | if (pos != NULL) { | 820 | if (pos != NULL) { |
805 | *pos='\0'; | 821 | *pos='\0'; |
diff --git a/archival/tar.c b/archival/tar.c index 0fa09ffd8..6496231ae 100644 --- a/archival/tar.c +++ b/archival/tar.c | |||
@@ -40,6 +40,7 @@ | |||
40 | #include <utime.h> | 40 | #include <utime.h> |
41 | #include <sys/types.h> | 41 | #include <sys/types.h> |
42 | #include <sys/sysmacros.h> | 42 | #include <sys/sysmacros.h> |
43 | #include <sys/param.h> /* for PATH_MAX */ | ||
43 | 44 | ||
44 | 45 | ||
45 | #ifdef BB_FEATURE_TAR_CREATE | 46 | #ifdef BB_FEATURE_TAR_CREATE |
@@ -1041,7 +1042,7 @@ static void saveDirectory (const char *dirName, const struct stat *statbuf) | |||
1041 | DIR *dir; | 1042 | DIR *dir; |
1042 | struct dirent *entry; | 1043 | struct dirent *entry; |
1043 | int needSlash; | 1044 | int needSlash; |
1044 | char fullName[NAME_MAX]; | 1045 | char fullName[PATH_MAX + 1]; |
1045 | 1046 | ||
1046 | /* | 1047 | /* |
1047 | * Construct the directory name as used in the tar file by appending | 1048 | * Construct the directory name as used in the tar file by appending |