<feed xmlns='http://www.w3.org/2005/Atom'>
<title>busybox.git/testsuite/awk.tests, branch master</title>
<subtitle>Unnamed repository; edit this file 'description' to name the repository.
</subtitle>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/busybox.git/'/>
<entry>
<title>awk: restore assignment precedence to be lower than ternary ?:</title>
<updated>2024-07-09T13:30:46+00:00</updated>
<author>
<name>Denys Vlasenko</name>
<email>vda.linux@googlemail.com</email>
</author>
<published>2024-07-09T13:30:46+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/busybox.git/commit/?id=38335df9e9f45378c3407defd38b5b610578bdda'/>
<id>38335df9e9f45378c3407defd38b5b610578bdda</id>
<content type='text'>
Something is fishy with constrcts like "3==v=3" in gawk,
they should not work, but do. Ignore those for now.

Signed-off-by: Denys Vlasenko &lt;vda.linux@googlemail.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Something is fishy with constrcts like "3==v=3" in gawk,
they should not work, but do. Ignore those for now.

Signed-off-by: Denys Vlasenko &lt;vda.linux@googlemail.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>awk: fix handling of empty fields</title>
<updated>2023-12-31T14:49:54+00:00</updated>
<author>
<name>Denys Vlasenko</name>
<email>vda.linux@googlemail.com</email>
</author>
<published>2023-12-31T14:49:54+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/busybox.git/commit/?id=789ccac7d9d1a9e433570ac9628992a01f946643'/>
<id>789ccac7d9d1a9e433570ac9628992a01f946643</id>
<content type='text'>
Patch by M Rubon &lt;rubonmtz@gmail.com&gt;:
Busybox awk handles references to empty (not provided in the input)
fields differently during the first line of input, as compared to
subsequent lines.

$ (echo a ; echo b) | awk '$2 != 0'    #wrong
b

No field $2 value is provided in the input.  When awk references field
$2 for the "a" line, it is seen to have a different behaviour than
when it is referenced for the "b" line.

Problem in BusyBox v1.36.1 embedded in OpenWrt 23.05.0
Same problem also in 21.02 versions of OpenWrt
Same problem in BusyBox v1.37.0.git

I get the correct expected output from Ubuntu gawk and Debian mawk,
and from my fix.
will@dev:~$ (echo a ; echo b) | awk '$2 != 0'  #correct
a
b
will@dev:~/busybox$ (echo a ; echo b ) | ./busybox awk '$2 != 0'  #fixed
a
b

I built and poked into the source code at editors/awk.c  The function
fsrealloc(int size) is core to allocating, initializing, reallocating,
and reinitializing fields, both real input line fields and imaginary
fields that the script references but do not exist in the input.

When fsrealloc() needs more field space than it has previously
allocated, it initializes those new fields differently than how they
are later reinitialized for the next input line.  This works fine for
fields defined in the input, like $1, but does not work the first time
when there is no input for that field (e.g. field $99)

My one-line fix simply makes the initialization and clrvar()
reinitialization use the same value for .type.  I am not sure if there
are regression tests to run, but I have not done those.

I'm not sure if I understand why clrvar() is not setting .type to a
default constant value, but in any case I have left that untouched.

function                                             old     new   delta
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/0 up/down: 0/0)                 Total: 0 bytes

Signed-off-by: Denys Vlasenko &lt;vda.linux@googlemail.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Patch by M Rubon &lt;rubonmtz@gmail.com&gt;:
Busybox awk handles references to empty (not provided in the input)
fields differently during the first line of input, as compared to
subsequent lines.

$ (echo a ; echo b) | awk '$2 != 0'    #wrong
b

No field $2 value is provided in the input.  When awk references field
$2 for the "a" line, it is seen to have a different behaviour than
when it is referenced for the "b" line.

Problem in BusyBox v1.36.1 embedded in OpenWrt 23.05.0
Same problem also in 21.02 versions of OpenWrt
Same problem in BusyBox v1.37.0.git

I get the correct expected output from Ubuntu gawk and Debian mawk,
and from my fix.
will@dev:~$ (echo a ; echo b) | awk '$2 != 0'  #correct
a
b
will@dev:~/busybox$ (echo a ; echo b ) | ./busybox awk '$2 != 0'  #fixed
a
b

I built and poked into the source code at editors/awk.c  The function
fsrealloc(int size) is core to allocating, initializing, reallocating,
and reinitializing fields, both real input line fields and imaginary
fields that the script references but do not exist in the input.

When fsrealloc() needs more field space than it has previously
allocated, it initializes those new fields differently than how they
are later reinitialized for the next input line.  This works fine for
fields defined in the input, like $1, but does not work the first time
when there is no input for that field (e.g. field $99)

My one-line fix simply makes the initialization and clrvar()
reinitialization use the same value for .type.  I am not sure if there
are regression tests to run, but I have not done those.

I'm not sure if I understand why clrvar() is not setting .type to a
default constant value, but in any case I have left that untouched.

function                                             old     new   delta
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/0 up/down: 0/0)                 Total: 0 bytes

Signed-off-by: Denys Vlasenko &lt;vda.linux@googlemail.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>awk: fix subst code to handle "start of word" pattern correctly (needs REG_STARTEND)</title>
<updated>2023-06-08T08:42:39+00:00</updated>
<author>
<name>Denys Vlasenko</name>
<email>vda.linux@googlemail.com</email>
</author>
<published>2023-06-08T08:42:39+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/busybox.git/commit/?id=2ca39ffd447ca874fcea933194829717d5573247'/>
<id>2ca39ffd447ca874fcea933194829717d5573247</id>
<content type='text'>
function                                             old     new   delta
awk_sub                                              637     714     +77

Signed-off-by: Denys Vlasenko &lt;vda.linux@googlemail.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
function                                             old     new   delta
awk_sub                                              637     714     +77

Signed-off-by: Denys Vlasenko &lt;vda.linux@googlemail.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>awk: fix backslash handling in sub() builtins</title>
<updated>2023-06-02T22:42:10+00:00</updated>
<author>
<name>Denys Vlasenko</name>
<email>vda.linux@googlemail.com</email>
</author>
<published>2023-06-02T22:39:33+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/busybox.git/commit/?id=5f84c5633663f6ee8c9cc3a4608b86d4b56b39d6'/>
<id>5f84c5633663f6ee8c9cc3a4608b86d4b56b39d6</id>
<content type='text'>
function                                             old     new   delta
awk_sub                                              559     544     -15

Signed-off-by: Denys Vlasenko &lt;vda.linux@googlemail.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
function                                             old     new   delta
awk_sub                                              559     544     -15

Signed-off-by: Denys Vlasenko &lt;vda.linux@googlemail.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>awk: fix precedence of = relative to ==</title>
<updated>2023-05-30T14:44:04+00:00</updated>
<author>
<name>Denys Vlasenko</name>
<email>vda.linux@googlemail.com</email>
</author>
<published>2023-05-30T14:42:18+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/busybox.git/commit/?id=0256e00a9d077588bd3a39f5a1ef7e2eaa2911e4'/>
<id>0256e00a9d077588bd3a39f5a1ef7e2eaa2911e4</id>
<content type='text'>
Discovered while adding code to disallow assignments to non-lvalues

function                                             old     new   delta
parse_expr                                           936     991     +55
.rodata                                           105243  105247      +4
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 59/0)               Total: 59 bytes

Signed-off-by: Denys Vlasenko &lt;vda.linux@googlemail.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Discovered while adding code to disallow assignments to non-lvalues

function                                             old     new   delta
parse_expr                                           936     991     +55
.rodata                                           105243  105247      +4
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 59/0)               Total: 59 bytes

Signed-off-by: Denys Vlasenko &lt;vda.linux@googlemail.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>awk: fix splitting with default FS</title>
<updated>2023-05-27T14:17:38+00:00</updated>
<author>
<name>Denys Vlasenko</name>
<email>vda.linux@googlemail.com</email>
</author>
<published>2023-05-27T14:16:58+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/busybox.git/commit/?id=84ff1825dd82e8de45020e3def34d1430d8e5a99'/>
<id>84ff1825dd82e8de45020e3def34d1430d8e5a99</id>
<content type='text'>
function                                             old     new   delta
awk_split                                            543     544      +1

Signed-off-by: Denys Vlasenko &lt;vda.linux@googlemail.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
function                                             old     new   delta
awk_split                                            543     544      +1

Signed-off-by: Denys Vlasenko &lt;vda.linux@googlemail.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>awk: fix use-after-realloc (CVE-2021-42380), closes 15601</title>
<updated>2023-05-26T17:36:58+00:00</updated>
<author>
<name>Denys Vlasenko</name>
<email>vda.linux@googlemail.com</email>
</author>
<published>2023-05-26T17:36:58+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/busybox.git/commit/?id=5dcc443dba039b305a510c01883e9f34e42656ae'/>
<id>5dcc443dba039b305a510c01883e9f34e42656ae</id>
<content type='text'>
Signed-off-by: Denys Vlasenko &lt;vda.linux@googlemail.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Signed-off-by: Denys Vlasenko &lt;vda.linux@googlemail.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>awk: fix use after free (CVE-2022-30065)</title>
<updated>2022-07-11T15:18:07+00:00</updated>
<author>
<name>Natanael Copa</name>
<email>ncopa@alpinelinux.org</email>
</author>
<published>2022-06-17T15:45:34+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/busybox.git/commit/?id=e63d7cdfdac78c6fd27e9e63150335767592b85e'/>
<id>e63d7cdfdac78c6fd27e9e63150335767592b85e</id>
<content type='text'>
fixes https://bugs.busybox.net/show_bug.cgi?id=14781

function                                             old     new   delta
evaluate                                            3343    3357     +14

Signed-off-by: Natanael Copa &lt;ncopa@alpinelinux.org&gt;
Signed-off-by: Denys Vlasenko &lt;vda.linux@googlemail.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
fixes https://bugs.busybox.net/show_bug.cgi?id=14781

function                                             old     new   delta
evaluate                                            3343    3357     +14

Signed-off-by: Natanael Copa &lt;ncopa@alpinelinux.org&gt;
Signed-off-by: Denys Vlasenko &lt;vda.linux@googlemail.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>awk: input numbers are never octal or hex (only program consts can be)</title>
<updated>2022-01-08T21:42:35+00:00</updated>
<author>
<name>Denys Vlasenko</name>
<email>vda.linux@googlemail.com</email>
</author>
<published>2022-01-08T21:42:35+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/busybox.git/commit/?id=e2952dfaff67f3641d3a6d3226753356170ff808'/>
<id>e2952dfaff67f3641d3a6d3226753356170ff808</id>
<content type='text'>
function                                             old     new   delta
next_token                                           825     930    +105
getvar_i                                             114     129     +15
nextchar                                              49      53      +4
my_strtod                                            138       -    -138
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 3/0 up/down: 124/-138)          Total: -14 bytes

Signed-off-by: Denys Vlasenko &lt;vda.linux@googlemail.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
function                                             old     new   delta
next_token                                           825     930    +105
getvar_i                                             114     129     +15
nextchar                                              49      53      +4
my_strtod                                            138       -    -138
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 3/0 up/down: 124/-138)          Total: -14 bytes

Signed-off-by: Denys Vlasenko &lt;vda.linux@googlemail.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>awk: fix printf %%</title>
<updated>2021-09-05T01:42:51+00:00</updated>
<author>
<name>Daniel Thau</name>
<email>danthau@bedrocklinux.org</email>
</author>
<published>2021-09-02T11:41:08+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/busybox.git/commit/?id=7d06d6e18651cb183a3723fa21ef62935ea08647'/>
<id>7d06d6e18651cb183a3723fa21ef62935ea08647</id>
<content type='text'>
A refactor of the awk printf code in
e2e3802987266c98df0efdf40ad5da4b07df0113
appears to have broken the printf interpretation of two percent signs,
which normally outputs only one percent sign.

The patch below brings busybox awk printf behavior back into alignment
with the pre-e2e380 behavior, the busybox printf util, and other common
(awk and non-awk) printf implementations.

function                                             old     new   delta
awk_printf                                           626     672     +46

Signed-off-by: Daniel Thau &lt;danthau at bedrocklinux.org&gt;
Signed-off-by: Denys Vlasenko &lt;vda.linux@googlemail.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
A refactor of the awk printf code in
e2e3802987266c98df0efdf40ad5da4b07df0113
appears to have broken the printf interpretation of two percent signs,
which normally outputs only one percent sign.

The patch below brings busybox awk printf behavior back into alignment
with the pre-e2e380 behavior, the busybox printf util, and other common
(awk and non-awk) printf implementations.

function                                             old     new   delta
awk_printf                                           626     672     +46

Signed-off-by: Daniel Thau &lt;danthau at bedrocklinux.org&gt;
Signed-off-by: Denys Vlasenko &lt;vda.linux@googlemail.com&gt;
</pre>
</div>
</content>
</entry>
</feed>
