Re: [PATCH] ash: avoid GLIBC'ism %m
On 2017-07-18 9:15 PM, Kang-Che Sung wrote: On Wed, Jul 19, 2017 at 2:11 AM, Markus Gothewrote: Actually last time I checked ‘%m’ is POSIX contrary to glibc’s deprecated '%a’. However, I agree that it should not be used since at least uClibc can be built without support for it. How come %m is POSIX when I didn't see any mention of it in this page? http://pubs.opengroup.org/onlinepubs/9699919799/functions/fprintf.html It does not appear to be part of POSIX or the Single UNIX Specification. The glibc man page (as of 2016-12-12) even indicates that it is a glibc-specific extension: *m *(Glibc extension; supported by uClibc and musl.) Print output of /strerror(errno)/. No argument is required. The Gnulib manual has a pretty nice page mentioning several printf() incompatibilities and the operating systems they don't play nicely with: https://www.gnu.org/software/gnulib/manual/html_node/fprintf.html -Jody Bruchon ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [PATCH] ash: avoid GLIBC'ism %m
On Wed, Jul 19, 2017 at 2:11 AM, Markus Gothewrote: > Actually last time I checked ‘%m’ is POSIX contrary to glibc’s deprecated > '%a’. > However, I agree that it should not be used since at least uClibc can be > built without support for it. How come %m is POSIX when I didn't see any mention of it in this page? http://pubs.opengroup.org/onlinepubs/9699919799/functions/fprintf.html ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [PATCH 2/2] arch/{sparc,sparc64}/Makefile: define ARCH_FPIC
Hello, On Sat, 15 Jul 2017 14:44:21 +0200, Denys Vlasenko wrote: > Can you investigate this further? > LIBBUSYBOX build results in entire busybox code being put into a library. > > nm -D libbusybox.so.1.28.0.git > > shows that there are only defined entry points to each applet's main(): > > 0007b159 T bunzip2_main > 0007c8db T bzip2_main > 000677bb T cal_main > 0008e08e T cat_main > > (so, at max less than 350 entry points), and references to libc functions: > > U asprintf > U atof > U atoi > > No internal libbb functions or variables are exposed. > > I don't understand the error messages you are seeing. bb_errno should > have hidden visibility, > meaning that it is an internal (to libbusybox.so) label, and all > references to it > should be resolved without any shared linker magic. .LCn labels are > similar, they are > referring to text strings (messages and such). > > What is going on? Why your linker has relocations between individual > .o files which go > to the same library? I'm not really sure what's going on. But the problem can very easily be reproduced: $ git clone git://git.buildroot.org/buildroot $ cd buildroot/ $ cat > .config
1.27.1 is released
18 July 2017 -- BusyBox 1.27.1 (stable) BusyBox 1.27.1. (git, patches, how to add a patch) Bug fix release. 1.27.1 has fixes for uuencode (allow space instead of "`" as padding char), dd (fixed status=none), setpriv (option parsing should not eat options in PROG ARGS), fix for "applet (for example halt) as login shell" use case, a few fixes for less typical build environments. Split-out and monolithic i686 binaries available: https://busybox.net/downloads/binaries/1.27.1-i686/ 3 July 2017 -- BusyBox 1.27.0 (unstable) BusyBox 1.27.0. (git, patches, how to add a patch) Sizes of busybox-1.26.0 and busybox-1.27.0 (with equivalent config, static uclibc build): text databssdechexfilename 925769489 7352 933610 e3eeabusybox-1.26.0 927115489 7352 934956 e442c busybox-1.27.0 Changes since previous release: Andrei Gherzan: switch_root: don't bail out when console doesn't exist Andrey Mozzhuhin: ftpd: new option -a ANON_USER to allow anonymous logins André Draszik: iproute: support for filtering by and printing of scope Assaf Gordon: setpriv: new applet Ben Hutchings: modprobe: read modules.builtin Cristian Ionescu-Idbohrn: appletlib: avoid warning on unused function ingroup unzip: remove now-pointless lseek which returns current position Denys Vlasenko: fix "ifdef ENABLE_foo": should always be "#if ENABLE_foo" fix "loginutils/Config.in:319 error: Overlong line" make DPKG=y and DPKG_DEB=y by default make FEATURE_USERNAME_COMPLETION=y by default make INSMOD=y by default make RMMOD=y by default move FEATURE_AUTOWIDTH config option to two applets which use it move FEATURE_USE_TERMIOS config option to two applets which use it make_single_applets.sh: a tool to check single-applet builds qemu_multiarch_testing: small improvements archival: add option -k "keep" to gzip/bzip2/lzop, add -U "nokeep" to lzop libbb: consolidate the code to set termios unbuffered mode libbb: eliminate redundant variable in sha_crypt libbb: fix "error: redefinition of 'is_tty_secure'" libbb: make check_password() also return CHECKPASS_PW_HAS_EMPTY_PASSWORD libbb: match_fstype() is unreadable in the extreme, fixing it libbb: move isqrt from factor, use it in diff too libbb: shrink dump.c libbb: spawn_and_wait() fflushes before forking NOEXEC; child reinits logmode libiproute: FACT_FUNCization add/remove-shell: copy /etc/shells mode to new file ash: 16-bit nprocs field is a pain for many CPUs ash: add INT_OFF/ON around allocations ash: commented-out possible fix for 7694 ash: error out if ASH_INTERNAL_GLOB is not selected on uClibc ash: fix a bug in argv restoration after sourcing a file ash: fix $HOME/.profile reading if !ASH_EXPAND_PRMT ash: fix open fds leaking in redirects. Closes 9561 ash: fix 'trap - 65' ash: implement "exec -a ARGV0 CMD ARGV1..." ash: revert "make dot command search current directory first" hush: conditionalize print_escaped() on EXPORT || TRAP hush: correct exitcode for unterminated ')' - exitcode2.tests testcase hush: fix a bug in argv restoration after sourcing a file hush: fix 'defined but not used' warning hush: fix kill builtin without jobs support hush: global_args_malloced is used only if set builtin is enabled hush: kill builtin and kill %jobspec support hush: make echo builtin optional hush: make export builtin optional hush: make memleak builtin optional hush: make read and trap builtins optional hush: make set/unset builtins optional hush: make umask builtin optional hush: reinstate [[ builtin hush: remove redundand test for ENABLE_HUSH_JOB hush: reorder builtins (cd and pwd ought to be close, etc), no code changes hush: support %%, %+ and % jobspec (meaning "current job") ash,hush: fix SIGCHLD interrupting read builtin ash,hush: move "config" blocks above their use in coditional includes ash,hush: make hush test optional, rename ASH_BUILTIN_foo to ASH_foo ash,hush: make it possible to select "sh" and "bash" aliases without selecting ash or hush busybox: stop depending on FEATURE_AUTOWIDTH for applet list catv: convert this bbox-specific applet into "cat -v" cryptpw: support "rounds=NNN$" thing in salts depmod: don't build it if MODPROBE_SMALL=y diff: fix -N and nonexistent files. Closes 7454 factor: new applet fallocate: new applet fsfreeze: new applet ftpd/ls: show directories first grep: FEATURE_GREP_CONTEXT should be available for "fgrep only" too httpd: defend against attempts to OOM us. Closes 9611 httpd: use "Content-Length", not "-length" init: dont send "Sent SIGTERM to all"
Re: [PATCH] ash: avoid GLIBC'ism %m
Actually last time I checked ‘%m’ is POSIX contrary to glibc’s deprecated '%a’. However, I agree that it should not be used since at least uClibc can be built without support for it. BR, Markus - The panama-hat hacker On 17 Jul 2017, at 04:01 , Kang-Che Sungwrote: > I wonder if there's a better solution to this. > BusyBox has bb_perror_msg() and like. Maybe using these API's are better? > > On Mon, Jul 17, 2017 at 4:08 AM, Johannes Schindelin > wrote: >> GLIBC's printf() family supports the extension where the placeholder %m >> is interpolated to strerror(errno). >> >> This is not portable. So don't use it. (It was only used in ash's source >> code to begin with.) >> >> Signed-off-by: Johannes Schindelin >> --- >> Published-As: >> https://github.com/dscho/busybox-w32/releases/tag/busybox-glibc-ism-v1 >> Fetch-It-Via: git fetch https://github.com/dscho/busybox-w32 >> busybox-glibc-ism-v1 >> shell/ash.c | 14 -- >> 1 file changed, 8 insertions(+), 6 deletions(-) >> >> diff --git a/shell/ash.c b/shell/ash.c >> index b0c7dac54..e2ff15767 100644 >> --- a/shell/ash.c >> +++ b/shell/ash.c >> @@ -3809,8 +3809,10 @@ freejob(struct job *jp) >> static void >> xtcsetpgrp(int fd, pid_t pgrp) >> { >> - if (tcsetpgrp(fd, pgrp)) >> - ash_msg_and_raise_error("can't set tty process group (%m)"); >> + if (tcsetpgrp(fd, pgrp)) { >> + const char *err = strerror(errno); >> + ash_msg_and_raise_error("can't set tty process group (%s)", >> err); >> + } >> } >> >> /* >> @@ -5343,7 +5345,7 @@ savefd(int from) >>err = newfd < 0 ? errno : 0; >>if (err != EBADF) { >>if (err) >> - ash_msg_and_raise_error("%d: %m", from); >> + ash_msg_and_raise_error("%d: %s", from, >> strerror(errno)); >>close(from); >>fcntl(newfd, F_SETFD, FD_CLOEXEC); >>} >> @@ -5358,7 +5360,7 @@ dup2_or_raise(int from, int to) >>newfd = (from != to) ? dup2(from, to) : to; >>if (newfd < 0) { >>/* Happens when source fd is not open: try "echo >&99" */ >> - ash_msg_and_raise_error("%d: %m", from); >> + ash_msg_and_raise_error("%d: %s", from, strerror(errno)); >>} >>return newfd; >> } >> @@ -5489,7 +5491,7 @@ redirect(union node *redir, int flags) >>/* "echo >&10" and 10 is a fd opened to a sh script? >> */ >>if (is_hidden_fd(sv, right_fd)) { >>errno = EBADF; /* as if it is closed */ >> - ash_msg_and_raise_error("%d: %m", right_fd); >> + ash_msg_and_raise_error("%d: %s", right_fd, >> strerror(errno)); >>} >>newfd = -1; >>} else { >> @@ -5523,7 +5525,7 @@ redirect(union node *redir, int flags) >>if (newfd >= 0) >>close(newfd); >>errno = i; >> - ash_msg_and_raise_error("%d: %m", >> fd); >> + ash_msg_and_raise_error("%d: %s", >> fd, strerror(errno)); >>/* NOTREACHED */ >>} >>/* EBADF: it is not open - good, remember to >> close it */ >> >> base-commit: 68e980545af6a8ffb2980f94a6edac4dd89940f3 >> -- >> 2.13.3.windows.1.13.gaf0c2223da0 >> ___ >> busybox mailing list >> busybox@busybox.net >> http://lists.busybox.net/mailman/listinfo/busybox > ___ > busybox mailing list > busybox@busybox.net > http://lists.busybox.net/mailman/listinfo/busybox //Markus - The panama-hat hacker signature.asc Description: Message signed with OpenPGP using GPGMail ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [PATCH] printf: fix format string sanity check
Applied, thanks! On Tue, Jul 18, 2017 at 10:33 AM, Ron Yorstonwrote: > One of the tests for printf checks for an invalid bare '%' in the > format string: > >$ busybox printf '%' a b c >printf: %: invalid format > > On x86_64 a slightly different test doesn't work correctly: > >$ busybox printf '%' d e f >printf: invalid number 'd' >printf: invalid number 'e' >printf: invalid number 'f' > > On other platforms the test fails randomly depending on how the > arguments are laid out in memory. > > There are two places in the code where strchr is used to determine if > a character in the format string is valid. However, strchr also returns > a valid pointer if the character being searched for is the null terminator > thus causing the code to incorrectly suppose that a valid character has > been found. > > Add explicit checks for the null terminator. > > Signed-off-by: Ron Yorston > --- > coreutils/printf.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/coreutils/printf.c b/coreutils/printf.c > index bc22e0ee7..65bb5a935 100644 > --- a/coreutils/printf.c > +++ b/coreutils/printf.c > @@ -305,7 +305,7 @@ static char **print_formatted(char *f, char **argv, int > *conv_err) > } > break; > } > - if (strchr("-+ #", *f)) { > + if (*f && strchr("-+ #", *f)) { > ++f; > ++direc_length; > } > @@ -348,7 +348,7 @@ static char **print_formatted(char *f, char **argv, int > *conv_err) > static const char format_chars[] ALIGN1 = > "diouxXfeEgGcs"; > char *p = strchr(format_chars, *f); > /* needed - try "printf %" without it */ > - if (p == NULL) { > + if (p == NULL || *f == '\0') { > bb_error_msg("%s: invalid format", > direc_start); > /* causes main() to exit with error */ > return saved_argv - 1; > -- > 2.13.3 > > ___ > busybox mailing list > busybox@busybox.net > http://lists.busybox.net/mailman/listinfo/busybox ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
[PATCH] printf: fix format string sanity check
One of the tests for printf checks for an invalid bare '%' in the format string: $ busybox printf '%' a b c printf: %: invalid format On x86_64 a slightly different test doesn't work correctly: $ busybox printf '%' d e f printf: invalid number 'd' printf: invalid number 'e' printf: invalid number 'f' On other platforms the test fails randomly depending on how the arguments are laid out in memory. There are two places in the code where strchr is used to determine if a character in the format string is valid. However, strchr also returns a valid pointer if the character being searched for is the null terminator thus causing the code to incorrectly suppose that a valid character has been found. Add explicit checks for the null terminator. Signed-off-by: Ron Yorston--- coreutils/printf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/coreutils/printf.c b/coreutils/printf.c index bc22e0ee7..65bb5a935 100644 --- a/coreutils/printf.c +++ b/coreutils/printf.c @@ -305,7 +305,7 @@ static char **print_formatted(char *f, char **argv, int *conv_err) } break; } - if (strchr("-+ #", *f)) { + if (*f && strchr("-+ #", *f)) { ++f; ++direc_length; } @@ -348,7 +348,7 @@ static char **print_formatted(char *f, char **argv, int *conv_err) static const char format_chars[] ALIGN1 = "diouxXfeEgGcs"; char *p = strchr(format_chars, *f); /* needed - try "printf %" without it */ - if (p == NULL) { + if (p == NULL || *f == '\0') { bb_error_msg("%s: invalid format", direc_start); /* causes main() to exit with error */ return saved_argv - 1; -- 2.13.3 ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox