From d0119d15f97750c49f9955e6c6f952f03d72e795 Mon Sep 17 00:00:00 2001 From: Denis Vlasenko Date: Wed, 27 Dec 2006 04:44:51 +0000 Subject: [PATCH] Simple fixes accumulated after 1.3.0. busybox-1.3.0.ash.patch busybox-1.3.0.bb_strtou.patch busybox-1.3.0.CONFIG_FEATURE_TAR_GNU_EXTENSIONS.patch busybox-1.3.0.dhcprelay.patch busybox-1.3.0.dpkg_ar.patch busybox-1.3.0.find.patch busybox-1.3.0.mount.patch busybox-1.3.0.perror.patch busybox-1.3.0.sed.patch busybox-1.3.0.shadow.patch busybox-1.3.0.xregcomp.patch --- archival/libunarchive/get_header_ar.c | 23 ++++++++++++++++------- archival/libunarchive/get_header_tar.c | 4 +++- editors/sed.c | 3 ++- findutils/find.c | 4 +++- include/libbb.h | 2 ++ include/xatonum.h | 14 +++++++------- libbb/Kbuild | 2 ++ libbb/bb_strtonum.c | 1 + libbb/perror_nomsg.c | 9 ++++++--- libbb/perror_nomsg_and_die.c | 10 ++++++---- networking/udhcp/dhcprelay.c | 3 ++- shell/ash.c | 4 ++-- util-linux/mount.c | 3 +++ 13 files changed, 55 insertions(+), 27 deletions(-) diff --git a/archival/libunarchive/get_header_ar.c b/archival/libunarchive/get_header_ar.c index 7f8c81ca0..897c89918 100644 --- a/archival/libunarchive/get_header_ar.c +++ b/archival/libunarchive/get_header_ar.c @@ -9,6 +9,7 @@ char get_header_ar(archive_handle_t *archive_handle) { + int err; file_header_t *typed = archive_handle->file_header; union { char raw[60]; @@ -45,15 +46,23 @@ char get_header_ar(archive_handle_t *archive_handle) archive_handle->offset += 60; /* align the headers based on the header magic */ - if ((ar.formatted.magic[0] != '`') || (ar.formatted.magic[1] != '\n')) { + if (ar.formatted.magic[0] != '`' || ar.formatted.magic[1] != '\n') bb_error_msg_and_die("invalid ar header"); - } - typed->mode = xstrtoul(ar.formatted.mode, 8); - typed->mtime = xatou(ar.formatted.date); - typed->uid = xatou(ar.formatted.uid); - typed->gid = xatou(ar.formatted.gid); - typed->size = xatoul(ar.formatted.size); + /* FIXME: more thorough routine would be in order here */ + /* (we have something like that in tar) */ + /* but for now we are lax. This code works because */ + /* on misformatted numbers bb_strtou returns all-ones */ + typed->mode = err = bb_strtou(ar.formatted.mode, NULL, 8); + if (err == -1) bb_error_msg_and_die("invalid ar header"); + typed->mtime = err = bb_strtou(ar.formatted.date, NULL, 10); + if (err == -1) bb_error_msg_and_die("invalid ar header"); + typed->uid = err = bb_strtou(ar.formatted.uid, NULL, 10); + if (err == -1) bb_error_msg_and_die("invalid ar header"); + typed->gid = err = bb_strtou(ar.formatted.gid, NULL, 10); + if (err == -1) bb_error_msg_and_die("invalid ar header"); + typed->size = err = bb_strtou(ar.formatted.size, NULL, 10); + if (err == -1) bb_error_msg_and_die("invalid ar header"); /* long filenames have '/' as the first character */ if (ar.formatted.name[0] == '/') { diff --git a/archival/libunarchive/get_header_tar.c b/archival/libunarchive/get_header_tar.c index 66c3314a1..88f72bd15 100644 --- a/archival/libunarchive/get_header_tar.c +++ b/archival/libunarchive/get_header_tar.c @@ -74,8 +74,10 @@ char get_header_tar(archive_handle_t *archive_handle) if (sizeof(tar) != 512) BUG_tar_header_size(); - again: +#if ENABLE_FEATURE_TAR_GNU_EXTENSIONS + again: +#endif /* Align header */ data_align(archive_handle, 512); diff --git a/editors/sed.c b/editors/sed.c index ac3d8d463..a6544fd0d 100644 --- a/editors/sed.c +++ b/editors/sed.c @@ -120,7 +120,6 @@ struct sed_globals { } bbg; -void sed_free_and_close_stuff(void); #if ENABLE_FEATURE_CLEAN_UP static void sed_free_and_close_stuff(void) { @@ -156,6 +155,8 @@ static void sed_free_and_close_stuff(void) while (bbg.current_input_file < bbg.input_file_count) fclose(bbg.input_file_list[bbg.current_input_file++]); } +#else +void sed_free_and_close_stuff(void); #endif /* If something bad happens during -i operation, delete temp file */ diff --git a/findutils/find.c b/findutils/find.c index bf6b71a83..c49a0010a 100644 --- a/findutils/find.c +++ b/findutils/find.c @@ -81,6 +81,7 @@ static inline int one_char(const char* str, char c) } +#if ENABLE_FEATURE_FIND_EXEC static int count_subst(const char *str) { int count = 0; @@ -108,6 +109,7 @@ static char* subst(const char *src, int count, const char* filename) strcpy(dst, src); return buf; } +#endif static int exec_actions(action ***appp, const char *fileName, struct stat *statbuf) @@ -562,8 +564,8 @@ int find_main(int argc, char **argv) argp[0] = "-a"; } argp++; - } #endif + } actions = parse_params(&argv[firstopt]); diff --git a/include/libbb.h b/include/libbb.h index 1d91a0a72..65430d254 100644 --- a/include/libbb.h +++ b/include/libbb.h @@ -51,7 +51,9 @@ #include "pwd_.h" #include "grp_.h" +#if ENABLE_FEATURE_SHADOWPASSWDS #include "shadow_.h" +#endif /* Try to pull in PATH_MAX */ #include diff --git a/include/xatonum.h b/include/xatonum.h index 585d84623..8b1663789 100644 --- a/include/xatonum.h +++ b/include/xatonum.h @@ -115,7 +115,7 @@ extern inline unsigned long bb_strtoul(const char *arg, char **endp, int base) { return bb_strtoull(arg, endp, base); } extern inline -unsigned long bb_strtol(const char *arg, char **endp, int base) +long bb_strtol(const char *arg, char **endp, int base) { return bb_strtoll(arg, endp, base); } #else unsigned long bb_strtoul(const char *arg, char **endp, int base); @@ -124,21 +124,21 @@ long bb_strtol(const char *arg, char **endp, int base); #if UINT_MAX == ULLONG_MAX extern inline -unsigned long bb_strtou(const char *arg, char **endp, int base) +unsigned bb_strtou(const char *arg, char **endp, int base) { return bb_strtoull(arg, endp, base); } extern inline -unsigned long bb_strtoi(const char *arg, char **endp, int base) +int bb_strtoi(const char *arg, char **endp, int base) { return bb_strtoll(arg, endp, base); } #elif UINT_MAX == ULONG_MAX extern inline -unsigned long bb_strtou(const char *arg, char **endp, int base) +unsigned bb_strtou(const char *arg, char **endp, int base) { return bb_strtoul(arg, endp, base); } extern inline -unsigned long bb_strtoi(const char *arg, char **endp, int base) +int bb_strtoi(const char *arg, char **endp, int base) { return bb_strtol(arg, endp, base); } #else -unsigned long bb_strtou(const char *arg, char **endp, int base); -long bb_strtoi(const char *arg, char **endp, int base); +unsigned bb_strtou(const char *arg, char **endp, int base); +int bb_strtoi(const char *arg, char **endp, int base); #endif int BUG_bb_strtou32_unimplemented(void); diff --git a/libbb/Kbuild b/libbb/Kbuild index c15615302..827a5ce9f 100644 --- a/libbb/Kbuild +++ b/libbb/Kbuild @@ -113,5 +113,7 @@ lib-$(CONFIG_EJECT) += find_mount_point.o lib-$(CONFIG_AWK) += xregcomp.o lib-$(CONFIG_SED) += xregcomp.o +lib-$(CONFIG_GREP) += xregcomp.o lib-$(CONFIG_LESS) += xregcomp.o +lib-$(CONFIG_MDEV) += xregcomp.o lib-$(CONFIG_DEVFSD) += xregcomp.o diff --git a/libbb/bb_strtonum.c b/libbb/bb_strtonum.c index 6fbd1f87d..50ef0ba26 100644 --- a/libbb/bb_strtonum.c +++ b/libbb/bb_strtonum.c @@ -17,6 +17,7 @@ * errno = ERANGE if value had alphanumeric terminating char ("1234abcg"). * errno = ERANGE if value is out of range, missing, etc. * errno = ERANGE if value had minus sign for strtouXX (even "-0" is not ok ) + * return value is all-ones in this case. */ static unsigned long long ret_ERANGE(void) diff --git a/libbb/perror_nomsg.c b/libbb/perror_nomsg.c index 3aefd5301..8059f9fd8 100644 --- a/libbb/perror_nomsg.c +++ b/libbb/perror_nomsg.c @@ -7,10 +7,13 @@ * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. */ -#include "libbb.h" +/* gcc warns about a null format string, therefore we provide + * modified definition without "attribute (format)" + * instead of including libbb.h */ +//#include "libbb.h" +extern void bb_perror_msg(const char *s, ...); void bb_perror_nomsg(void) { - /* Ignore the gcc warning about a null format string. */ - bb_perror_msg(NULL); + bb_perror_msg(0); } diff --git a/libbb/perror_nomsg_and_die.c b/libbb/perror_nomsg_and_die.c index e5623c2a9..c416df67c 100644 --- a/libbb/perror_nomsg_and_die.c +++ b/libbb/perror_nomsg_and_die.c @@ -7,11 +7,13 @@ * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. */ -#include -#include "libbb.h" +/* gcc warns about a null format string, therefore we provide + * modified definition without "attribute (format)" + * instead of including libbb.h */ +//#include "libbb.h" +extern void bb_perror_msg_and_die(const char *s, ...); void bb_perror_nomsg_and_die(void) { - /* Ignore the gcc warning about a null format string. */ - bb_perror_msg_and_die(NULL); + bb_perror_msg_and_die(0); } diff --git a/networking/udhcp/dhcprelay.c b/networking/udhcp/dhcprelay.c index e3a816886..4e84b8dd4 100644 --- a/networking/udhcp/dhcprelay.c +++ b/networking/udhcp/dhcprelay.c @@ -259,7 +259,8 @@ static void dhcprelay_loop(int *fds, int num_sockets, int max_socket, char **cli { struct dhcpMessage dhcp_msg; fd_set rfds; - size_t packlen, addr_size; + size_t packlen; + socklen_t addr_size; struct sockaddr_in client_addr; struct timeval tv; int i; diff --git a/shell/ash.c b/shell/ash.c index 3a9998fc0..976c3f78a 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -85,7 +85,7 @@ #ifdef CONFIG_ASH_JOB_CONTROL #define JOBS 1 #else -#undef JOBS +#define JOBS 0 #endif #if JOBS || defined(CONFIG_ASH_READ_NCHARS) @@ -6647,7 +6647,7 @@ usage: } #endif /* JOBS */ -#if defined(JOBS) || DEBUG +#if JOBS || DEBUG static int jobno(const struct job *jp) { diff --git a/util-linux/mount.c b/util-linux/mount.c index f8ae1df19..0fcd8e561 100644 --- a/util-linux/mount.c +++ b/util-linux/mount.c @@ -1693,10 +1693,13 @@ int mount_main(int argc, char **argv) // Mount this thing. + // NFS mounts want this to be xrealloc-able + mtcur->mnt_opts = xstrdup(mtcur->mnt_opts); if (singlemount(mtcur, 1)) { /* Count number of failed mounts */ rc++; } + free(mtcur->mnt_opts); } } if (ENABLE_FEATURE_CLEAN_UP) endmntent(fstab); -- 2.25.1