From 8ea7d8cdaf4a03cdc06abc8b752b589271140a88 Mon Sep 17 00:00:00 2001 From: Erik Andersen Date: Sat, 20 May 2000 00:40:08 +0000 Subject: [PATCH] First pass at fixing tar segfault, and more portability updates. -Erik --- TODO | 5 +++++ archival/tar.c | 5 +++-- cmdedit.c | 6 ++++++ fsck_minix.c | 1 + internal.h | 12 ------------ mkfs_minix.c | 5 +---- shell/cmdedit.c | 6 ++++++ tar.c | 5 +++-- util-linux/fsck_minix.c | 1 + util-linux/mkfs_minix.c | 5 +---- 10 files changed, 27 insertions(+), 24 deletions(-) diff --git a/TODO b/TODO index 7ab43c36d..febd9bf51 100644 --- a/TODO +++ b/TODO @@ -22,6 +22,11 @@ Bugs that need fixing: - 'grep *foo file' segfaults - ps dirent race bug (need to stat the file before attempting chdir) + +/busybox tar tvf +Segmentation fault (core dumped) + + ----------- * Make insmod actually work diff --git a/archival/tar.c b/archival/tar.c index 6784d80ff..c5aad45d6 100644 --- a/archival/tar.c +++ b/archival/tar.c @@ -185,7 +185,7 @@ extern int tar_main(int argc, char **argv) usage(tar_usage); /* Parse any options */ - while (--argc > 0 && **(++argv) == '-') { + while (--argc > 0 && strspn(*(++argv), "-cxt") >0 ) { stopIt=FALSE; while (stopIt==FALSE && *(++(*argv))) { switch (**argv) { @@ -265,7 +265,8 @@ extern int tar_main(int argc, char **argv) #else exit(writeTarFile(tarName, tostdoutFlag, verboseFlag, argc, argv, excludeList)); #endif - } else { + } + if (listFlag == TRUE || extractFlag == TRUE) { exit(readTarFile(tarName, extractFlag, listFlag, tostdoutFlag, verboseFlag, excludeList)); } diff --git a/cmdedit.c b/cmdedit.c index e4c88c265..22831b10c 100644 --- a/cmdedit.c +++ b/cmdedit.c @@ -70,6 +70,12 @@ static struct history *his_end = NULL; /* Last element in command line list */ /* Current termio and the previous termio before starting sh */ struct termios initial_settings, new_settings; + + +#ifndef _POSIX_VDISABLE +#define _POSIX_VDISABLE '\0' +#endif + #endif diff --git a/fsck_minix.c b/fsck_minix.c index 7d27566b8..1e482f3f9 100644 --- a/fsck_minix.c +++ b/fsck_minix.c @@ -97,6 +97,7 @@ #include #include #include +#include #include #include diff --git a/internal.h b/internal.h index 9c55f5a49..909bf6473 100644 --- a/internal.h +++ b/internal.h @@ -284,18 +284,6 @@ int nfsmount(const char *spec, const char *node, unsigned long *flags, char **extra_opts, char **mount_opts, int running_bg); #endif -#if defined (BB_FSCK_MINIX) || defined (BB_MKFS_MINIX) -/* Bit map related macros. */ -#ifndef setbit -#define CHAR_BITS 8 /* Number of bits in a `char'. */ -#define setbit(a,i) ((a)[(i)/CHAR_BITS] |= 1<<((i)%CHAR_BITS)) -#define clrbit(a,i) ((a)[(i)/CHAR_BITS] &= ~(1<<((i)%CHAR_BITS))) -#define isset(a,i) ((a)[(i)/CHAR_BITS] & (1<<((i)%CHAR_BITS))) -#define isclr(a,i) (((a)[(i)/CHAR_BITS] & (1<<((i)%CHAR_BITS))) == 0) -#endif -#endif - - #ifndef RB_POWER_OFF /* Stop system and switch power off if possable. */ #define RB_POWER_OFF 0x4321fedc diff --git a/mkfs_minix.c b/mkfs_minix.c index f4f1d0997..c6f057a07 100644 --- a/mkfs_minix.c +++ b/mkfs_minix.c @@ -74,6 +74,7 @@ #include #include #include +#include #include #include @@ -83,10 +84,6 @@ #define HAVE_MINIX2 1 #endif -#ifndef __GNUC__ -#error "needs gcc for the bitop-__asm__'s" -#endif - #ifndef __linux__ #define volatile #endif diff --git a/shell/cmdedit.c b/shell/cmdedit.c index e4c88c265..22831b10c 100644 --- a/shell/cmdedit.c +++ b/shell/cmdedit.c @@ -70,6 +70,12 @@ static struct history *his_end = NULL; /* Last element in command line list */ /* Current termio and the previous termio before starting sh */ struct termios initial_settings, new_settings; + + +#ifndef _POSIX_VDISABLE +#define _POSIX_VDISABLE '\0' +#endif + #endif diff --git a/tar.c b/tar.c index 6784d80ff..c5aad45d6 100644 --- a/tar.c +++ b/tar.c @@ -185,7 +185,7 @@ extern int tar_main(int argc, char **argv) usage(tar_usage); /* Parse any options */ - while (--argc > 0 && **(++argv) == '-') { + while (--argc > 0 && strspn(*(++argv), "-cxt") >0 ) { stopIt=FALSE; while (stopIt==FALSE && *(++(*argv))) { switch (**argv) { @@ -265,7 +265,8 @@ extern int tar_main(int argc, char **argv) #else exit(writeTarFile(tarName, tostdoutFlag, verboseFlag, argc, argv, excludeList)); #endif - } else { + } + if (listFlag == TRUE || extractFlag == TRUE) { exit(readTarFile(tarName, extractFlag, listFlag, tostdoutFlag, verboseFlag, excludeList)); } diff --git a/util-linux/fsck_minix.c b/util-linux/fsck_minix.c index 7d27566b8..1e482f3f9 100644 --- a/util-linux/fsck_minix.c +++ b/util-linux/fsck_minix.c @@ -97,6 +97,7 @@ #include #include #include +#include #include #include diff --git a/util-linux/mkfs_minix.c b/util-linux/mkfs_minix.c index f4f1d0997..c6f057a07 100644 --- a/util-linux/mkfs_minix.c +++ b/util-linux/mkfs_minix.c @@ -74,6 +74,7 @@ #include #include #include +#include #include #include @@ -83,10 +84,6 @@ #define HAVE_MINIX2 1 #endif -#ifndef __GNUC__ -#error "needs gcc for the bitop-__asm__'s" -#endif - #ifndef __linux__ #define volatile #endif