| Commit message (Collapse) | Author | Age | Files | Lines |
| ... | |
| | |
| |
| |
| |
| |
| | |
It was already disabled (ASH_OPTIMIZE_FOR_SIZE is 0 by default),
and it saved ~ 40 bytes but with big hit on performance, so not
really worth it. This also makes actype.c less noisy.
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Unify actype/actail into a single function, and make actype
a wrapper macro which invokes actail(str, NULL) (to avoid calling
a function actype which then trampolines to actail with NULL).
This concludes the integration of actype/isactype.
Overall:
- Unified/standard-ish char-class handling in fnmatch/regcomp/tr.
- Saved about 1400 bytes at the binary as x64.
- regcomp.c is negligibly faster (actype/isactype are O(1)).
- tr.c now also supports [:graph:] and [:print:], and not slower.
fnmatch.c (tested using scripts/patbench.sh):
Before actype was integrated, alnum was fastest and xdigit slowest
due to their order in the names strings list and in the switch/case:
[35] 1305 ms OK (M:12-45) '*[0-9A-Za-z]*[0-9A-Za-z]'
[36] 1928 ms OK (M:12-45) '*[[:alnum:]]*[[:alnum:]]'
[38] 1446 ms OK (M:12-45) '*[a-bc-de-z]*[a-bc-de-z]'
[39] 3192 ms OK (M:12-45) '*[[:lower:]]*[[:lower:]]'
[40] 1586 ms OK (M:---4-) '*[0-9A-Fa-ef]*[0-9A-Fa-ef]'
[41] 4601 ms OK (M:---4-) '*[[:xdigit:]]*[[:xdigit:]]'
Now all classes are similar relative to an equivalent range,
and just barely slower than "alnum" before actype was added
(still slower than range due to additional temp name buffer):
[35] 1402 ms OK (M:12-45) '*[0-9A-Za-z]*[0-9A-Za-z]'
[36] 1962 ms OK (M:12-45) '*[[:alnum:]]*[[:alnum:]]'
[38] 1453 ms OK (M:12-45) '*[a-bc-de-z]*[a-bc-de-z]'
[39] 1965 ms OK (M:12-45) '*[[:lower:]]*[[:lower:]]'
[40] 1683 ms OK (M:---4-) '*[0-9A-Fa-ef]*[0-9A-Fa-ef]'
[41] 2117 ms OK (M:---4-) '*[[:xdigit:]]*[[:xdigit:]]'
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The premise, and implementation, is simple: instead of doing string
search in a list of strings for the class name - which is fast for the
first strings in the list but slow for the last strings, use perfect
hash to map the string directly to a potential class to match in O(1).
The switch/case in isactype is also changed to a function table in O(1)
(the compiler might have optimized this switch to O(1) jump-table, but
now we don't leave it to chance).
Two implementations are supported: one which allows testing actype_t
value against specific classes like AC_ALNUM etc, and one which doesn't
allow that (just like wctype/iswctype) and is more efficient.
Since nothing uses specific class matches anymore, default is the more
efficient choice - where actype_t is a function pointer to isalnum etc.
And while at it, also change the enum names CCLASS_ALNUM etc to more
appropriate AC_ALNUM etc, to use the AC "namespace".
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
tr implements its own char classes setup, using index_in_strings and
"precompiling" the various classes chars. We can replace the lot with
a single loop of actail/isactype, which saves about 500 bytes.
Additionally, for unclear reasons, it didn't support [:graph:] and
[:print:], maybe because isgraph and isprint are disabled in libbb.h
because they're locale-dependent.
The new implementation using ac* does add support for these, and so tr
on windows now supports e.g. 'tr [:print:] X' which it didn't before.
This is the first use of actail, and demonstrates the usecases for it
(win32/fnmatch.c could use it as well, but the current code is too
branched to use it while keeping identical behavior, and regcomp.c
extracts the name from [:NAME:] on its own).
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
This saves more than 1K size because the original switch code expanded
a two-loops macro - BUILD_CHARCLASS_LOOP in each of the 12 "case".
Performance is non critical here in regcomp, but nevertheless, a future
commit will optimize actype/isactype, and especially isactype_not0
(which is used here with non-0 type).
Also:
- "#if 0" was replaced with "#ifndef CONFIG_BUSYBOX" for clarity.
- is_blank is no longer used, and disabled in this commit.
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
This preserves the original semantics where only ASCII chars are
tested, and unknown class name is considered known-but-unmatched name,
which is different than the equivalent wctype code just above.
The ASCII test is redundant, at least on windows - where all the
class tests (isalnum, isupper, etc) can only return true for ASCII
values, but nevertheless it's kept as the original semantics.
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
TL;DR:
- Add actype/isactype, like POSIX wctype/iswctype, but single-byte.
- actype is a renamed match_class, isactype is yet unused.
- This can be used in win32/{fnmatch,regcomp}.c, and elsewhere - tr.c.
Details:
win32/fnmatch.c and win32/regcomp.c used match_class to get char-class
index for char-class name, which is then used in a switch statement to
choose the single-byte isupper, isalpha, etc.
This is analogous to the POSIX wctype/iswctype, except that wctype
returns 0 for unknown name but match_class returned -1.
This commit renames match_class to actype:
- Returns 0 for unknown name, which at the enum is a new CCLASS_NONE.
- Return type is actype_t (still enum), analogous to wctype_t.
- Rename match_class* to actype* at fname/kbuild/includes/usage.
Both fnmatch.c and regcomp.c don't care whether unknown name in
match_class/actype is -1 (match_class) or 0 (actype). All they care
about is the values at each "case".
Also implemented, but not yet used:
- isactype(c, t): test whether char c is of type t.
- isactype_not0(c, t): when t is not-0 - same as isactype but faster.
- actail(s, int*): test for "NAME:]..." without temporary buffer.
Note that this commit focuses on exposing a useful API rather than
performance. Future commits may improve actype/isactype performance.
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Few minor improvements:
- Add few valid but edge-case patterns (start with ']' etc).
- Add the expected result for default lines, and report ok/err.
- Disable measurements with -mn (to be measured externally).
Also, the default lines were modified slightly so that the new
edge cases results are largely distinct, so it can be used as
correctness test with -d (and exit code is 1 on errors).
BENCHMARK RESULTS
Below are results of running this script using busybox-w32 on win10,
and using busybox on Alpine linux 3.23.
Observations of busybox-w32 results, which uses old glibc fnmatch:
[10] 129 ms OK (M:12345) '*[hello world, this is a test]*'
[42] 22491 ms OK (M:12-45) '*[0-9A-Za-z]*[0-9A-Za-z]*[0-9A-Za-z]'
The current busybox-w32 implementation is exponential, and while
tests of simple patterns complete in 100-200ms, patterns with 3 '*'
can take 30s or more to complete, way longer with 4 '*', etc.
[12] 192 ms E:1-3-- (M:-----) '*[*'
[13] 201 ms E:1---- (M:-----) '*[]*'
[14] 203 ms E:--3-- (M:-----) '*[!]*'
A bracket which doesn't start a bracket expression is regular char,
and all these are missing the closing bracket (by POSIX rules), and
should be matched literally, but the current fnmatch fails with that.
[35] 1305 ms OK (M:12-45) '*[0-9A-Za-z]*[0-9A-Za-z]'
[36] 1928 ms OK (M:12-45) '*[[:alnum:]]*[[:alnum:]]'
[38] 1446 ms OK (M:12-45) '*[a-bc-de-z]*[a-bc-de-z]'
[39] 3192 ms OK (M:12-45) '*[[:lower:]]*[[:lower:]]'
[40] 1586 ms OK (M:---4-) '*[0-9A-Fa-ef]*[0-9A-Fa-ef]'
[41] 4601 ms OK (M:---4-) '*[[:xdigit:]]*[[:xdigit:]]'
charclass [:alnum:] is x1.4 slower than an equivalent non-class range,
but [:lower:] is already x2 slower than the equivalent, and [:xdigit:]
is x3 slower than the equivalent. This is because the name is searched
in a list which starts with "alnum" and ends in "xdigit", and the
search duration (and the following switch in the same order) clearly
affects how quickly a pattern can be tested.
There are other issues in busybox-w32 fnmatch, like incorrect
case-insensitivity and more, but which don't manifest in case...esac.
Benchmark results with busybox-w32 on Windows 10 (compiled with gcc):
[ 1] 107 ms OK (M:-----) ''
[ 2] 108 ms OK (M:12345) '*'
[ 3] 104 ms OK (M:-----) '@'
[ 4] 112 ms OK (M:1----) 'Lorem*'
[ 5] 120 ms OK (M:-2---) '*quis'
[ 6] 127 ms OK (M:--3--) '*nisi*'
[ 7] 244 ms OK (M:--3--) '*[fobar]xyz*'
[ 8] 544 ms OK (M:--3--) '*[foobarfoobarfoobarfoobar]xyz*'
[ 9] 588 ms OK (M:-2---) '*[!foobarfoobarfoobarfoobar]xyz*'
[10] 129 ms OK (M:12345) '*[hello world, this is a test]*'
[11] 136 ms OK (M:12345) '*[!hello world, this is a test]*'
[12] 192 ms E:1-3-- (M:-----) '*[*'
[13] 201 ms E:1---- (M:-----) '*[]*'
[14] 203 ms E:--3-- (M:-----) '*[!]*'
[15] 182 ms OK (M:-23-5) '*[!]].*'
[16] 454 ms OK (M:1----) '*[![:print:]]*'
[17] 124 ms OK (M:-23--) '*z*'
[18] 123 ms OK (M:---4-) '*-*'
[19] 160 ms OK (M:---4-) '*[-]*'
[20] 175 ms OK (M:-234-) '*[-z]*'
[21] 177 ms OK (M:-234-) '*[z-]*'
[22] 197 ms OK (M:-234-) '*[-z-]*'
[23] 126 ms OK (M:1-3--) '*]*'
[24] 168 ms OK (M:1-3--) '*[]]*'
[25] 173 ms OK (M:1-34-) '*[]-]*'
[26] 168 ms OK (M:123--) '*[]-_]*'
[27] 170 ms OK (M:1234-) '*[]-_-]*'
[28] 365 ms OK (M:12-45) '*[0-9A-Za-z][0-9A-Za-z]'
[29] 513 ms OK (M:12-45) '*[[:alnum:]][[:alnum:]]'
[30] 263 ms OK (M:12-45) '*[a-z][a-z]'
[31] 376 ms OK (M:12-45) '*[a-bc-de-z][a-bc-de-z]'
[32] 815 ms OK (M:12-45) '*[[:lower:]][[:lower:]]'
[33] 311 ms OK (M:-----) '*[0-9A-Fa-ef][0-9A-Fa-ef]'
[34] 756 ms OK (M:-----) '*[[:xdigit:]][[:xdigit:]]'
[35] 1305 ms OK (M:12-45) '*[0-9A-Za-z]*[0-9A-Za-z]'
[36] 1928 ms OK (M:12-45) '*[[:alnum:]]*[[:alnum:]]'
[37] 919 ms OK (M:12-45) '*[a-z]*[a-z]'
[38] 1446 ms OK (M:12-45) '*[a-bc-de-z]*[a-bc-de-z]'
[39] 3192 ms OK (M:12-45) '*[[:lower:]]*[[:lower:]]'
[40] 1586 ms OK (M:---4-) '*[0-9A-Fa-ef]*[0-9A-Fa-ef]'
[41] 4601 ms OK (M:---4-) '*[[:xdigit:]]*[[:xdigit:]]'
[42] 22491 ms OK (M:12-45) '*[0-9A-Za-z]*[0-9A-Za-z]*[0-9A-Za-z]'
(aborted manually - exponential implementation becomes very slow)
results with busybox on Alpine linux 3.23 (musl-libc has linear-time
fnmatch, using wide-char wctype/iswctype - slightly slower than char):
[ 1] 135 ms OK (M:-----) ''
[ 2] 141 ms OK (M:12345) '*'
[ 3] 139 ms OK (M:-----) '@'
[ 4] 141 ms OK (M:1----) 'Lorem*'
[ 5] 148 ms OK (M:-2---) '*quis'
[ 6] 216 ms OK (M:--3--) '*nisi*'
[ 7] 410 ms OK (M:--3--) '*[fobar]xyz*'
[ 8] 787 ms OK (M:--3--) '*[foobarfoobarfoobarfoobar]xyz*'
[ 9] 844 ms OK (M:-2---) '*[!foobarfoobarfoobarfoobar]xyz*'
[10] 215 ms OK (M:12345) '*[hello world, this is a test]*'
[11] 237 ms OK (M:12345) '*[!hello world, this is a test]*'
[12] 206 ms OK (M:1-3--) '*[*'
[13] 242 ms OK (M:1----) '*[]*'
[14] 220 ms OK (M:--3--) '*[!]*'
[15] 306 ms OK (M:-23-5) '*[!]].*'
[16] 591 ms OK (M:1----) '*[![:print:]]*'
[17] 216 ms OK (M:-23--) '*z*'
[18] 198 ms OK (M:---4-) '*-*'
[19] 286 ms OK (M:---4-) '*[-]*'
[20] 285 ms OK (M:-234-) '*[-z]*'
[21] 291 ms OK (M:-234-) '*[z-]*'
[22] 299 ms OK (M:-234-) '*[-z-]*'
[23] 228 ms OK (M:1-3--) '*]*'
[24] 286 ms OK (M:1-3--) '*[]]*'
[25] 267 ms OK (M:1-34-) '*[]-]*'
[26] 349 ms OK (M:123--) '*[]-_]*'
[27] 292 ms OK (M:1234-) '*[]-_-]*'
[28] 198 ms OK (M:12-45) '*[0-9A-Za-z][0-9A-Za-z]'
[29] 201 ms OK (M:12-45) '*[[:alnum:]][[:alnum:]]'
[30] 179 ms OK (M:12-45) '*[a-z][a-z]'
[31] 217 ms OK (M:12-45) '*[a-bc-de-z][a-bc-de-z]'
[32] 205 ms OK (M:12-45) '*[[:lower:]][[:lower:]]'
[33] 202 ms OK (M:-----) '*[0-9A-Fa-ef][0-9A-Fa-ef]'
[34] 203 ms OK (M:-----) '*[[:xdigit:]][[:xdigit:]]'
[35] 215 ms OK (M:12-45) '*[0-9A-Za-z]*[0-9A-Za-z]'
[36] 213 ms OK (M:12-45) '*[[:alnum:]]*[[:alnum:]]'
[37] 191 ms OK (M:12-45) '*[a-z]*[a-z]'
[38] 219 ms OK (M:12-45) '*[a-bc-de-z]*[a-bc-de-z]'
[39] 224 ms OK (M:12-45) '*[[:lower:]]*[[:lower:]]'
[40] 217 ms OK (M:---4-) '*[0-9A-Fa-ef]*[0-9A-Fa-ef]'
[41] 199 ms OK (M:---4-) '*[[:xdigit:]]*[[:xdigit:]]'
[42] 227 ms OK (M:12-45) '*[0-9A-Za-z]*[0-9A-Za-z]*[0-9A-Za-z]'
[43] 239 ms OK (M:12-45) '*[[:alnum:]]*[[:alnum:]]*[[:alnum:]]'
[44] 204 ms OK (M:12-45) '*[a-z]*[a-z]*[a-z]'
[45] 258 ms OK (M:12-45) '*[a-bc-de-z]*[a-bc-de-z]*[a-bc-de-z]'
[46] 235 ms OK (M:12-45) '*[[:lower:]]*[[:lower:]]*[[:lower:]]'
[47] 247 ms OK (M:---4-) '*[0-9A-Fa-ef]*[0-9A-Fa-ef]*[0-9A-Fa-ef]'
[48] 247 ms OK (M:---4-) '*[[:xdigit:]]*[[:xdigit:]]*[[:xdigit:]]'
[49] 286 ms OK (M:12-45) '*[0-9A-Za-z]*[0-9A-Za-z]*[0-9A-Za-z]*[0-9A-Za-z]'
[50] 262 ms OK (M:12-45) '*[[:alnum:]]*[[:alnum:]]*[[:alnum:]]*[[:alnum:]]'
[51] 219 ms OK (M:12-45) '*[a-z]*[a-z]*[a-z]*[a-z]'
[52] 273 ms OK (M:12-45) '*[a-bc-de-z]*[a-bc-de-z]*[a-bc-de-z]*[a-bc-de-z]'
[53] 274 ms OK (M:12-45) '*[[:lower:]]*[[:lower:]]*[[:lower:]]*[[:lower:]]'
[54] 281 ms OK (M:---4-) '*[0-9A-Fa-ef]*[0-9A-Fa-ef]*[0-9A-Fa-ef]*[0-9A-Fa-ef]'
[55] 296 ms OK (M:---4-) '*[[:xdigit:]]*[[:xdigit:]]*[[:xdigit:]]*[[:xdigit:]]'
|
| | |
| |
| |
| |
| | |
This script measures the performance of shell pattern matching,
with increasing pattern complexity (more '*' at the pattern).
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The 'patch' applet was unable to process diffs which included the
'\ No newline at end of file' warning.
Detect this case and mark the lines affected so they can be
emitted without a newline.
Adds 45-69 bytes.
(GitHub issue #575)
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Move existing code which obtains process execution times into a
separate function. Use it to allow times(2) to report execution
times for the current process, though not child execution times.
Change TICKS_PER_SECOND from 100 to 1000 to increase the displayed
resolution of process times (though the measured resolution may
well be less than this).
Adds 48-80 bytes.
(GitHub issue #574)
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Overlong UTF8 encoding means that a codepoint is encoded using more
bytes than necessary, and it's disallowed.
Until now we didn't reject it, e.g. 2-bytes sequence of 0xc0 0x9b
was incorrectly decoded as codepoint 0x1b (ESC), but it's overlong
because 1-byte 0x1b is enough for this codepoint.
Now we reject such sequences and print '?' (CONFIG_SUBST_WCHAR).
Additionally, we now also reject 4-bytes sequences which end up above
the maximum valid codepoint value (0x10ffff). No such issue with 1/2/3
bytes UTF-8 because technically only 4 can encode a too big value.
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Upstream BusyBox uses the '-fdata-sections' compiler flag. On
Windows this has the unfortunate side effect that static variables
are placed in the .data section, thus increasing the size of the
binary.
Add a configuration option, STATICS_IN_BSS, to force statics into
.bss on Windows, saving 2-5KB for most binaries. It has no
effect on POSIX builds, where statics are always placed in .bss.
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The "nwritten" argument and failure conditions were added in commit
208649d7b5, as it crashed on windows XP without it, and specifically
because WriteConsoleW on XP expects this to be a non-NULL argument.
However, writeCon_utf8 should not be called on XP - and indeed it's
not since commit 234a3b97d3, because it produces incorrect output
unless the UTF8 manifest is in effect - which never happens on XP.
So it was called due to a bug, and it's not called on XP anymore.
Nevertheless, it's possible that in the future we will support native
Windows Unicode without the manifest - also on XP, and in such case
writeCon_utf8 might get called on XP as well, so keep this argument.
However the nwritten failure condition doesn't belong here.
It's not needed on XP, and MS docs doesn't say that this value should
tested in addition to the return value in order to determine failure,
and theoretically there could be differences unrelated to failure.
So ignore this value when determining failure. Return value is enough.
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Previously, at writeCon_utf8, when we detected an invalid byte (for
the current state), then we printed one '?' which also covered any
following invalid bytes, until a valid byte for state 0 was detected.
For instance printf '\377\377\377A' printed '?A' (3 bad bytes, 1 '?').
This was by design to avoid excessive '?' noise.
However, other terminals (xterm), and specifically windows console
(and terminal), print one '?' for any decoding error, and also reset
the decoding state after every error.
I.e. the same input would error 3 times, and display '???A'.
Now we do the same, which also happens to simplify the code.
The reference behavior is windows console/terminal in UTF-8 codepage
(which writeCon_utf8 tries to emulate in other console codepages).
To compare, do 'chcp 65001' to set the console to UTF-8 - which also
bypasses writeCon_utf8, and check how the terminal displays some
sequence. We should be the same, up to CONFIG_SUBST_WCHAR value.
The "state" comment is updated since we no longer maintain bad state.
While at it, refine also few nearby comments.
|
| | | |
|
| |\| |
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The size of the NFROMSTR struct wasn't initialised in the nodesize
array, so we got:
$ ./busybox sh
$ f() { cat <<< hello; }
$ f
Segmentation fault (core dumped) ./busybox sh
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
If the files being pasted had different numbers of lines the
output was incorrect.
Rewrite the loop over all lines to allow for this. Add tests for
such conditions.
function old new delta
paste_main 458 526 +68
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Commit 56143ea63 (ash: code shrink: eliminate pstrcmp1()) changed
the layout of struct builtincmd so the name member points to the
start of the name, not the flag in the first element of the string.
This broke the help builtin and tab completion of builtins.
Remove the unnecessary '+ 1' in ash_command_name() and helpcmd().
ash_command_name 92 91 -1
helpcmd 106 102 -4
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-5) Total: -5 bytes
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| |
| |
| |
| |
| |
| | |
commit 3fb6b31c7 introduced a check for unsafe components in
tar archive hardlinks, but it was being applied to symlinks too
which broke "Symlinks and hardlinks coexist" tar test.
Signed-off-by: Radoslav Kolev <radoslav.kolev@suse.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| | |
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
function old new delta
m_status_print 252 275 +23
status_print 111 122 +11
read_lines 783 775 -8
.rodata 107141 107131 -10
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/2 up/down: 34/-18) Total: 16 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
"less FILE" case needs it to be set just once. In other cases,
manipulate it less often.
function old new delta
read_lines 702 783 +81
reinitialize 198 199 +1
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 82/0) Total: 82 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Also: fewer syscalls to set/clear O_NONBLOCK, skip trying to read keyboard
if poll() told us it's not ready.
function old new delta
reinitialize 184 198 +14
getch_nowait 251 258 +7
sched_yield 25 - -25
read_lines 815 702 -113
------------------------------------------------------------------------------
(add/remove: 0/2 grow/shrink: 2/1 up/down: 21/-138) Total: -117 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
function old new delta
bb_get_servport_by_name - 348 +348
bb_lookup_port 83 111 +28
reread_config_file 886 907 +21
static.se 16 - -16
getservbyname 53 - -53
getservbyname_r 284 - -284
------------------------------------------------------------------------------
(add/remove: 2/5 grow/shrink: 2/0 up/down: 397/-353) Total: 44 bytes
text data bss dec hex filename
1080084 555 5024 1085663 1090df busybox_old
1080144 555 4992 1085691 1090fb busybox_unstripped
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| |
| |
| |
| | |
function old new delta
write_to_net 620 625 +5
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
function old new delta
bb_get_servname_by_port 182 195 +13
ip_port_str 121 120 -1
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 13/-1) Total: 12 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
function old new delta
bb_get_servname_by_port - 182 +182
ip_port_str 112 121 +9
pscan_main 594 591 -3
getservbyport 53 - -53
getservbyport_r 430 - -430
------------------------------------------------------------------------------
(add/remove: 2/4 grow/shrink: 1/1 up/down: 191/-486) Total: -295 bytes
text data bss dec hex filename
1080362 555 5056 1085973 109215 busybox_old
1080067 555 5024 1085646 1090ce busybox_unstripped
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
A few size tests were not tight enough. More importantly,
the logic "is this a telnet server?" made more robust.
TTYPE seems to be understood by the MUD server I tried,
for some reason NAWS is not?
function old new delta
packed_usage 36040 36078 +38
write_to_net 598 620 +22
telnet_main 455 462 +7
handle_SIGWINCH 15 21 +6
read_from_net 534 539 +5
show_menu 212 203 -9
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 5/1 up/down: 78/-9) Total: 69 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
function old new delta
telnetd_main 372 385 +13
make_new_session 550 552 +2
xgetpty 81 78 -3
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/1 up/down: 15/-3) Total: 12 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
function old new delta
write_to_stdout 105 113 +8
put_iac 28 35 +7
write_to_net 596 598 +2
read_from_stdin 227 229 +2
read_from_net 543 534 -9
telnet_main 476 455 -21
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 4/2 up/down: 19/-30) Total: -11 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Now should never block on network I/O. Also, window resizing is dynamic now.
function old new delta
write_to_net - 596 +596
read_from_net - 543 +543
read_from_stdin - 227 +227
show_menu - 212 +212
write_to_stdout - 105 +105
have_data_to_write_to_net - 72 +72
have_data_to_write_to_stdout - 38 +38
put_iac_byte_escaped - 32 +32
ioloop_run 411 438 +27
have_buffer_to_read_from_stdin - 25 +25
have_buffer_to_read_from_net - 25 +25
.rodata 107125 107141 +16
handle_SIGWINCH - 15 +15
put_iac 36 28 -8
put_iac4_msb_lsb 19 - -19
iac_flush 36 - -36
setConMode 87 - -87
handle_net_output 110 - -110
con_escape 271 - -271
telnet_main 1232 476 -756
------------------------------------------------------------------------------
(add/remove: 11/5 grow/shrink: 2/2 up/down: 1933/-1287) Total: 646 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| | |
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
If the the screen is resized to 255 columns without any
subsequent data received, the server won't parse and react
to the NAWS (until eventually at least one more byte arrives).
function old new delta
read_byte_unescaping_IAC 28 31 +3
net_to_pty__have_data_to_write 551 552 +1
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 4/0) Total: 4 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| |
| |
| |
| | |
function old new delta
static.iacs_to_send 12 9 -3
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
IOW: teach NAWS parser how to IAC-unescape.
function old new delta
net_to_pty__have_data_to_write 429 551 +122
read_byte_unescaping_IAC - 28 +28
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/0 up/down: 150/0) Total: 150 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
function old new delta
fabricate_ctrl_D_on_pty - 65 +65
net_to_pty__have_data_to_write 368 429 +61
.rodata 107096 107125 +29
telnetd_main 367 372 +5
net_to_pty__have_buffer_to_read_into 164 162 -2
packed_usage 36066 36040 -26
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 3/2 up/down: 160/-28) Total: 132 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
We do it, badly, in many places. Better to use one robust implementation.
Can be buggy yet.
Initial use is in a rather old, rarely used tech: telnet.
The I/O in telnetd should be fully non-blocking now,
including pty delays handling.
Several bugs in telnetd handling of IACs are fixed.
function old new delta
ioloop_run - 411 +411
net_to_pty__have_data_to_write - 368 +368
pty_to_net__write - 318 +318
net_to_pty__write - 180 +180
pty_to_net__read - 171 +171
net_to_pty__have_buffer_to_read_into - 164 +164
pty_to_net__have_buffer_to_read_into - 90 +90
net_to_pty__read - 87 +87
pty_to_net__have_data_to_write - 59 +59
make_new_session 491 550 +59
conn_close_fds - 52 +52
accept_conn__accept - 49 +49
conn_close_fds_remove_and_free - 27 +27
ioloop_remove_conn - 22 +22
remove_and_free_to_pty - 19 +19
ioloop_insert_conn - 10 +10
accept_conn__can_accept - 6 +6
accept_conn__return_zero - 3 +3
static.ayt_response - 2 +2
handle_sigchld 59 61 +2
free_session 130 - -130
telnetd_main 1797 367 -1430
------------------------------------------------------------------------------
(add/remove: 19/1 grow/shrink: 2/1 up/down: 2099/-1560) Total: 539 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| |
| |
| |
| | |
function old new delta
tls_handshake_as_server 2408 2400 -8
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
s_client
function old new delta
privRsaEncryptSignedElement - 236 +236
tls_handshake_as_server 2033 2264 +231
.rodata 108079 108301 +222
initialize_aes_keys - 77 +77
xwrite_encrypted 507 506 -1
tls_handshake 1519 1500 -19
derive_master_secret_and_keys 154 123 -31
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 2/3 up/down: 766/-51) Total: 715 bytes
Totoal growth compared to code before TLS server code:
function old new delta
tls_handshake_as_server - 2264 +2264
.rodata 107074 108301 +1227
psRsaCrypt - 577 +577
load_rsa_priv_key - 282 +282
ssl_server_main - 279 +279
privRsaEncryptSignedElement - 236 +236
ssl_client_main 137 363 +226
psRsaDecryptPriv - 171 +171
set_cipher_parameters - 161 +161
derive_master_secret_and_keys - 123 +123
packed_usage 36034 36146 +112
sp_ecc_make_key_256 - 103 +103
send_finished - 94 +94
get_change_cipher_spec - 88 +88
initialize_aes_keys - 77 +77
static.BLOCK_NAMES - 70 +70
curve_P256_compute_premaster - 65 +65
der_binary_to_pstm - 50 +50
curve_x25519_generate_keypair - 44 +44
get_finished - 42 +42
get_outbuf_fill_handshake_record - 37 +37
client_hello_ciphers - 32 +32
curve_P256_generate_keypair - 27 +27
sp_256_from_bin_8 - 26 +26
tls_xread_record 681 704 +23
curve_x25519_compute_premaster - 15 +15
applet_names 2870 2881 +11
applet_main 1652 1656 +4
xwrite_encrypted 507 506 -1
xwrite_and_update_handshake_hash 76 59 -17
sp_256_point_from_bin2x32 70 43 -27
curve_x25519_compute_pubkey_and_premaster 71 39 -32
curve_P256_compute_pubkey_and_premaster 167 65 -102
psRsaEncryptPub 395 199 -196
tls_handshake 2069 1500 -569
------------------------------------------------------------------------------
(add/remove: 23/0 grow/shrink: 6/7 up/down: 6466/-944) Total: 5522 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
function old new delta
tls_handshake_as_server 1601 2033 +432
sp_ecc_make_key_256 - 103 +103
curve_P256_compute_premaster - 65 +65
.rodata 108023 108079 +56
curve_x25519_generate_keypair - 44 +44
tls_get_zeroed_outbuf - 28 +28
curve_P256_generate_keypair - 27 +27
sp_256_from_bin_8 - 26 +26
curve_x25519_compute_premaster - 15 +15
tls_xread_record 708 704 -4
tls_handshake 1530 1519 -11
get_outbuf_fill_handshake_record 51 37 -14
sp_256_point_from_bin2x32 70 43 -27
curve_x25519_compute_pubkey_and_premaster 71 39 -32
curve_P256_compute_pubkey_and_premaster 167 65 -102
------------------------------------------------------------------------------
(add/remove: 7/0 grow/shrink: 2/6 up/down: 796/-190) Total: 606 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
function old new delta
.rodata 108007 108023 +16
psRsaDecryptPriv 200 171 -29
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 16/-29) Total: -13 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
ECDSA keys still don't work, and currently will be ignored
function old new delta
tls_handshake_as_server 824 1601 +777
.rodata 107764 108007 +243
set_cipher_parameters - 161 +161
packed_usage 36072 36146 +74
static.BLOCK_NAMES - 70 +70
client_hello_ciphers - 32 +32
ssl_server_main 288 279 -9
load_rsa_priv_key 329 282 -47
tls_handshake 1676 1530 -146
------------------------------------------------------------------------------
(add/remove: 3/0 grow/shrink: 3/3 up/down: 1357/-202) Total: 1155 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
with fill_handshake_record_hdr()
function old new delta
get_outbuf_fill_handshake_record - 51 +51
send_finished 95 94 -1
tls_handshake 1690 1676 -14
xwrite_and_update_handshake_hash 76 59 -17
tls_handshake_as_server 852 824 -28
tls_get_zeroed_outbuf 28 - -28
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 0/4 up/down: 51/-88) Total: -37 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| | |
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
function old new delta
tls_handshake_as_server 7 852 +845
.rodata 107103 107764 +661
psRsaCrypt - 577 +577
load_rsa_priv_key - 329 +329
psRsaDecryptPriv - 200 +200
derive_master_secret_and_keys - 154 +154
send_finished - 95 +95
get_change_cipher_spec - 88 +88
der_binary_to_pstm - 50 +50
get_finished - 42 +42
tls_xread_record 681 708 +27
ssl_server_main 285 288 +3
psRsaEncryptPub 395 199 -196
tls_handshake 2069 1690 -379
------------------------------------------------------------------------------
(add/remove: 8/0 grow/shrink: 4/2 up/down: 3071/-575) Total: 2496 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
function old new delta
ssl_server_main - 285 +285
ssl_client_main 137 363 +226
packed_usage 36034 36072 +38
.rodata 107074 107103 +29
applet_names 2870 2881 +11
tls_handshake_as_server - 7 +7
applet_main 1652 1656 +4
------------------------------------------------------------------------------
(add/remove: 3/0 grow/shrink: 5/0 up/down: 600/0) Total: 600 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| | |
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| |
| |
| |
| |
| |
| | |
Newer glibc is now smarter and can propagate const-ness from those!
function old new delta
readtoken1 3111 3108 -3
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|