aboutsummaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
...
* | win32: code shrinkRon Yorston2020-02-133-19/+15
| | | | | | | | | | Have bs_to_slash() return a pointer to its argument. This allows some calls to be chained, saving 32 bytes.
* | date: code shrinkRon Yorston2020-02-113-7/+27
| | | | | | | | | | | | | | Since we don't have a working clock_settime(2) there's no point in claiming to support the '-s' option. Saves 96 bytes
* | ash: code shrinkRon Yorston2020-02-111-3/+15
| | | | | | | | | | | | | | Since we don't support execution of signal traps or the 'trap hack' there's no need for the may_have_traps variable or trap_ptr. Saves 64 bytes.
* | ash: fixes to trapRon Yorston2020-02-101-3/+4
| | | | | | | | | | | | | | If a trap is set for SIGINT don't call raise(SIGINT) in preadfd(), otherwise the shell exits because the signal isn't being caught. In forkshell_init() change the initialisation of trap and trap_ptr.
* | ash: don't compile dotrap()Ron Yorston2020-02-081-0/+6
| | | | | | | | | | | | | | | | Since signal handling isn't functional for WIN32 there's no need to compile dotrap(). Some elements of the globals_misc structure can also be excluded. Saves 144 bytes.
* | ash: fixes to handling of ctrl-C in read builtinRon Yorston2020-02-082-2/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Consider this script: while read -r; do echo $REPLY; done echo hello There are currently two problems with this when the read is interrupted by ctrl-C: - The error return code is 0 when it should be 130; - The echo command is executed. Fix these issues by propagating the control event to the process that would have caught it if the read builtin hadn't grabbed keyboard input.
* | ash: catch EOF in read builtinRon Yorston2020-02-081-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The read builtin didn't detect EOF so it wasn't possible to cleanly terminate a loop like: while read -r; do echo $REPLY; done Consider how Linux handles EOF (represented as ^D, though this isn't echoed): $ awk '{print}' | xxd abc^D123 ^D 00000000: 6162 6331 3233 0a abc123. Contrast with busybox-w32 on Windows (where the ^Z is echoed): $ awk '{print}' | xxd abc^Z123 ^Z 00000000: 6162 631a 3132 330a abc.123. In both cases EOF is only detected at the start of a line. On Linux EOF within a line is dropped; on Windows it's output as a literal ctrl-Z. Implement similar behaviour for the read builtin.
* | ash: process backspace in read builtinRon Yorston2020-02-071-0/+10
| | | | | | | | | | | | | | | | | | | | | | Previously the 'read' builtin had no special treatment for backspace characters entered in interactive mode: they were simply added to the string being read. Change this so that backspace deletes the previous character from the buffer and updates the display to match. It still doesn't handle tabs in the input or lines that are larger than the console width.
* | winansi: fix alternate screen buffer in Windows 7Ron Yorston2020-02-061-6/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | Closing 'vi' in Windows 7 resulted in the console window failing to echo any output correctly until the 'reset' builtin was run. This didn't happen in Windows XP, 8 or 10. The problem is fixed by only duplicating the console handle when switching *to* the alternate screen buffer. Add sanity checks so that switching to the alternate buffer requires the cached handled to be invalid, while it must be valid when switching from the alternate buffer.
* | ash: remove obsolete commentRon Yorston2020-02-041-4/+1
| |
* | ash: tidy up history_copy()Ron Yorston2020-01-211-6/+6
| | | | | | | | No change in functionality or executable size.
* | mingw: fix off-by-one error in mingw_strftime()Ron Yorston2020-01-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | When a format specification is replaced the loop variable 't' should point to the last character of the replacement string in the new format buffer. In an extreme case if the original format string is "%z" and tm->tm_isdst is negative to indicate that no DST information is available the replacement string will be empty and 't' will point to the location before the start of the new format buffer. This is OK.
* | mingw: fix use after free in file_owner()Ron Yorston2020-01-191-9/+6
| | | | | | | | | | The security descriptor was being freed before its contents were accessed.
* | ash: fix out of bounds read in tblentry_copy()Ron Yorston2020-01-191-1/+1
| | | | | | | | | | | | Commit 2ffcb860e (ash: minor fixes to forkshell handling) ensured that tblentry structures were properly aligned but also resulted in reads beyond the end of the allocated structure.
* | ash: reduce size of forkshell relocation mapRon Yorston2020-01-181-70/+77
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The functions to calculate the size of the forkshell data block returned the total size of funcblock and funcstring. The relocation map only needs to cover the size of the forkshell structure plus funcblock, not funcstring. Revise the *_size() functions to distinguish between funcblock and funcstring. Avoid complicating the calculation of node sizes (calcsize() and related functions). This slightly overestimates the size of funcblock by including strings stored in node structures. This change increases the binary by 96 bytes but can save several thousand bytes at runtime.
* | ash: simplify MARK_PTR macroRon Yorston2020-01-181-9/+16
| | | | | | | | | | | | | | The MARK_PTR macro was unnecessarily complex. Since the relocation map is a fixed offset from the start of the forkshell structure we can obtain a pointer to the flag corresponding to a given destination pointer knowing just the pointer and the offset. Saves 324 bytes.
* | ash: reorder SAVE_PTR macrosRon Yorston2020-01-181-10/+8
| | | | | | | | | | | | Group together the code to mark pointers in the relocation map and that to store annotations. This allows some optimisations when forkshell debugging is enabled, saving 32 bytes.
* | ash: relocatesize may differ from forkshell block sizeRon Yorston2020-01-181-9/+12
| | | | | | | | | | | | | | Currently the size of the relocate map is equal to the size of the forkshell struct plus funcblock and funcstring. This may not always be the case so record the size of the map separately. This doesn't affect the size of the binary.
* | ash: rework how pointers are adjusted during forkshellRon Yorston2020-01-161-229/+185
| | | | | | | | | | | | | | | | | | | | The original code kept an array of pointers to pointers that needed to be adjusted after forkshell (nodeptr). Switch to using a map to indicate which locations in the data block need to be adjusted. This requires a larger data block. However the *_size() functions which calculate the data block size need less information about the data structures. Saves about 100 bytes in the binary.
* | ash: minor fixes to forkshell handlingRon Yorston2020-01-141-4/+2
| | | | | | | | | | | | | | | | Ensure that tblentry structures are properly aligned. The cmdname array has a size of one but the code doesn't allow for this in case upstream ever switches to using an empty array. Remove a couple of unnecessary increments.
* | Build fixesFRP-3329-gcf0fa4d13Ron Yorston2020-01-085-6/+18
| | | | | | | | | | | | - Update configuration files - Omit unnecessary libraries - Replace fake stime(2) with fake clock_settime(2)
* | Merge branch 'busybox' into mergeRon Yorston2020-01-0865-716/+1523
|\|
| * whois: limit total length of response to 32+2 kbDenys Vlasenko2019-12-031-1/+3
| | | | | | | | | | | | | | function old new delta query 517 554 +37 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * init: improve handling of signals racing with each otherDenys Vlasenko2019-12-031-159/+119
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before this change, a request to reboot could be "overwritten" by e.g. SIGHUP. function old new delta init_main 709 793 +84 packed_usage 33273 33337 +64 run_actions 109 117 +8 stop_handler 87 88 +1 check_delayed_sigs 340 335 -5 run 214 198 -16 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 4/2 up/down: 157/-21) Total: 136 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * init: if tcgetattr() fails, don't even try to tcsetattr()Denys Vlasenko2019-12-021-9/+8
| | | | | | | | | | | | | | function old new delta set_sane_term 111 114 +3 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush: fix preprocessor directives indentationDenys Vlasenko2019-11-281-32/+32
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * grep: add -RTomi Leppanen2019-11-271-3/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds -R option to grep similar to GNU grep. It is the same as -r but also dereferences symbolic links to directories. function old new delta grep_main 834 850 +16 packed_usage 33362 33368 +6 grep_file 1440 1441 +1 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 3/0 up/down: 23/0) Total: 23 bytes Signed-off-by: Tomi Leppanen <tomi.leppanen@jolla.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * bc: fix comparison bug, closes 12336Denys Vlasenko2019-11-232-1/+9
| | | | | | | | | | | | | | function old new delta bc_num_cmp 249 259 +10 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * Remove stime() function callsAlistair Francis2019-11-193-11/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | stime() has been deprecated in glibc 2.31 and replaced with clock_settime(). Let's replace the stime() function calls with clock_settime() in preperation. function old new delta rdate_main 197 224 +27 clock_settime - 27 +27 date_main 926 941 +15 stime 37 - -37 ------------------------------------------------------------------------------ (add/remove: 2/2 grow/shrink: 2/0 up/down: 69/-37) Total: 32 bytes Signed-off-by: Alistair Francis <alistair.francis@wdc.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * Updated inittab example documentationDenys Vlasenko2019-11-171-17/+30
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * chgrp: correct the usage for non-desktop chgrp callsLiu, Shuang (ADITG/ESM)2019-11-171-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When IF_DESKTOP is not defined, chown and chgrp only takes option -R -h, However the usage output of chgrp is wrong: $ ./busybox.nosuid chown Usage: chown [-Rh]... USER[:[GRP]] FILE... $ ./busybox.nosuid chgrp Usage: chgrp [-RhLHP]... GROUP FILE... $ ./busybox.nosuid chgrp -H group dummy chgrp: invalid option -- 'H' Usage: chgrp [-RhLHP]... GROUP FILE... The chgrp is now a wrapper of chown, so the recognized options shall be the same. This is introduced by 34425389e09353a8dacdd6b23a62553f699c544c I would expect the correct behavior shall be the same as chown. So suggest the below patch, the behavior shall be: $ ./busybox.nosuid chgrp Usage: chgrp [-Rh]... GROUP FILE... Signed-off-by: Shuang Liu <sliu@de.adit-jv.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * taskset: tighten the check for stride valuesDenys Vlasenko2019-11-091-2/+2
| | | | | | | | | | | | | | function old new delta taskset_main 986 987 +1 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * taskset: implement stride argumentDenys Vlasenko2019-11-091-5/+10
| | | | | | | | | | | | | | function old new delta taskset_main 925 986 +61 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * unxz: show -t in --helpDenys Vlasenko2019-11-081-0/+2
| | | | | | | | | | | | | | function old new delta packed_usage 33236 33247 +11 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * taskset: update commentDenys Vlasenko2019-11-081-2/+8
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * taskset: add support for taking/printing CPU list (-c option)Denys Vlasenko2019-11-011-11/+118
| | | | | | | | | | | | | | | | | | function old new delta taskset_main 511 855 +344 Based on patch by Fryderyk Wrobel <frd1996@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush: restore redirected stdinDenys Vlasenko2019-11-015-7/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | function old new delta restore_redirects 52 95 +43 save_fd_on_redirect 243 253 +10 hfopen 90 99 +9 fgetc_interactive 259 261 +2 builtin_type 117 115 -2 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 4/1 up/down: 64/-2) Total: 62 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ntpd: decrease MIN_FREQHOLD by 2, increase "penalty" for largish offset x2Denys Vlasenko2019-10-301-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > 2018-07-25: > ntpd: increase MIN_FREQHOLD by 3 > This means we'll start correcting frequency ~5 minutes after start, > not ~3.5 ones. > With previous settings I still often see largish ~0.7s initial offsets > only about 1/2 corrected before frequency correction kicks in, > resulting in ~200ppm "correction" which is then slowly undone. Review of real-world results of the above shows that with small initial offsets, freq correction can be allowed to kick in sooner, whereas with large (~0.8s) offsets, we still start freq correction a bit too soon. Let's rebalance this a bit. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * nslookup: implement support for SRV recordsJo-Philipp Wich2019-10-271-0/+20
| | | | | | | | | | | | | | | | | | | | | | Add support for querying and parsing SRV DNS records. function old new delta send_queries 1711 1865 +154 qtypes 72 80 +8 Signed-off-by: Jo-Philipp Wich <jo@mein.io> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * nslookup: handle replies without RRsJo-Philipp Wich2019-10-271-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Under some circumstances, a DNS reply might contain no resource records, e.g. when a valid domain is queried that does not have records of the requested type. Example with nslookup from BIND dnsutils: $ nslookup -q=SRV example.org Server: 10.11.12.13 Address: 10.11.12.13#53 Non-authoritative answer: *** Can't find example.org: No answer Currently the busybox nslookup applet simply prints nothing after the "Non-authoritative answer:" line in the same situation. This change modifies nslookup to either print "Parse error" or "No answer" diagnostics, depending on the parse_reply() return value. function old new delta send_queries 1676 1711 +35 Signed-off-by: Jo-Philipp Wich <jo@mein.io> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * gunzip: fix incorrect decoding of "fixed" inflate blocksDenys Vlasenko2019-10-261-10/+20
| | | | | | | | | | | | | | | | | | | | function old new delta huft_build 1008 1022 +14 inflate_block 1253 1256 +3 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 17/0) Total: 17 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hdparm: placate "warning: taking the absolute value of unsigned type"Denys Vlasenko2019-10-251-1/+1
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * vi: placate "warning: shifting a negative signed value is undefined"Denys Vlasenko2019-10-251-1/+1
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * read_key(): placate "warning: shifting a negative signed value is undefined"Denys Vlasenko2019-10-251-1/+2
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ntpd: abs(tmx.offset) was truncating a "long" typed valueDenys Vlasenko2019-10-251-2/+4
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * tc: array address is never NULLDenys Vlasenko2019-10-251-2/+0
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * traceroute: fix gcc-ismDenys Vlasenko2019-10-251-5/+5
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * suppress a few "unused function" warningsDenys Vlasenko2019-10-254-5/+6
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * netstat: suppress a warning (conversion from 'int' to 'smallint' changes value)Denys Vlasenko2019-10-251-1/+1
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * Makefile.flags: suppress some clang-9 warningsDenys Vlasenko2019-10-251-3/+22
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>