A few minor updates. ;-)
Seriously though, read the Changelog for busybox 0.42,
which this is about to become...
-Erik
diff --git a/gunzip.c b/gunzip.c
index fddcc76..db7fa1d 100644
--- a/gunzip.c
+++ b/gunzip.c
@@ -3,6 +3,9 @@
*/
#include "internal.h"
+#define bb_need_name_too_long
+#define BB_DECLARE_EXTERN
+#include "messages.c"
static const char gunzip_usage[] =
"gunzip [OPTION]... FILE\n\n"
@@ -64,6 +67,7 @@
#include <signal.h>
#include <sys/stat.h>
#include <errno.h>
+#include <sys/param.h> /* for PATH_MAX */
/* #include "tailor.h" */
@@ -627,8 +631,12 @@
#endif
#define RW_USER (S_IRUSR | S_IWUSR) /* creation mode for open() */
-#ifndef MAX_PATH_LEN
-# define MAX_PATH_LEN 1024 /* max pathname length */
+#ifndef MAX_PATH_LEN /* max pathname length */
+# ifdef PATH_MAX
+# define MAX_PATH_LEN PATH_MAX
+# else
+# define MAX_PATH_LEN 1024
+# endif
#endif
#ifndef SEEK_END
@@ -696,8 +704,8 @@
int delInputFile=0;
struct stat statBuf;
char* delFileName;
- char ifname[MAX_PATH_LEN]; /* input file name */
- char ofname[MAX_PATH_LEN]; /* output file name */
+ char ifname[MAX_PATH_LEN + 1]; /* input file name */
+ char ofname[MAX_PATH_LEN + 1]; /* output file name */
if (argc==1)
usage(gunzip_usage);
@@ -764,7 +772,11 @@
/* Open up the input file */
if (*argv=='\0')
usage(gunzip_usage);
- strncpy(ifname, *argv, MAX_PATH_LEN);
+ if (strlen(*argv) > MAX_PATH_LEN) {
+ fprintf(stderr, name_too_long, "gunzip");
+ do_exit(WARNING);
+ }
+ strcpy(ifname, *argv);
/* Open input fille */
inFileNum=open( ifname, O_RDONLY);
@@ -799,7 +811,11 @@
char* pos;
/* And get to work */
- strncpy(ofname, ifname, MAX_PATH_LEN-4);
+ if (strlen(ifname) > MAX_PATH_LEN - 4) {
+ fprintf(stderr, name_too_long, "gunzip");
+ do_exit(WARNING);
+ }
+ strcpy(ofname, ifname);
pos=strstr(ofname, ".gz");
if (pos != NULL) {
*pos='\0';