Commit Graph

69 Commits

Author SHA1 Message Date
Alex Richardson
1116946093 Fix another UBSan error in awk
This applies my upstreamed fix: ad9bd2f40a
Found By:	UBSan
2020-09-21 19:03:12 +00:00
Alex Richardson
ae692c42cb awk: Fix subobject out-of-bounds access
When matching a regex with ^, it would attempt to access
gototab[NSTATES][NCHARS+2], and therefore access the state for the \002
character instead. This change is required to run awk under CHERI (with
sub-object bounds) and when running with UBSan instrumentation.

This was committed upstream as cbf924342b

Found by:	CHERI (with subobject bounds enabled)
Obtained from:	CheriBSD
Reviewed By:	imp
Differential Revision: https://reviews.freebsd.org/D26509
2020-09-21 19:03:07 +00:00
Warner Losh
d9e8cf281b Another partial revert of r301289.
In this case, a change was made in one-true-awk from *FS to
getsval(fsloc) in a line just after one of the lines that had the 0 ->
NULL change. It works both ways as far as I can tell.  It looks like a
bug fix, but I've not tried to track down which ancient version of
one-true-awk it was in (github starts too late for tracking this
down). Before and after the changes the regression suite is passes
100% relative to the un-modified one-true-awk.
2019-06-03 05:25:22 +00:00
Warner Losh
31d232c2a3 Fix mismerge that crept into r301289.
The conversion of 0 -> NULL required a rebase at some point, as noted
in r301289 when pfg commited it. In that rebase, three lines remained
that had been removed in a prior version of awk, and one of them had a
0 -> NULL change causing a conflict. The conflict should have been
resolved by removing the three lines, but wasn't. This introduces a
regression into f.split3 test which prior to this commit we were
failing, but a pure onetrueawk wasn't. Remove the offending 3 lines.
2019-06-03 05:25:16 +00:00
Warner Losh
adb46ac4c0 Revert r348518
It should not have happened. The change is actually in upstream and I misread the diffs.
2019-06-02 20:52:21 +00:00
Warner Losh
2675e1b91d Reapply r301691:
Revert r301689 - one-true-awk: Avoid a NULL dereference.

I got this wrong and the coverity report doesn't match the NetBSD change,
which was thought for a different version.

The change wouldn't hurt but let's wait until upstream figures this out.
2019-06-02 20:47:15 +00:00
Warner Losh
06d1e65393 Reapply r315426 by pfg:
|    MFV r315425: one-true-awk: have calloc(3) do the multiplication.
2019-06-02 16:30:53 +00:00
Warner Losh
10ce5b990f Reapply r301289 by pfg:
|    MFV r300961: one-true-awk: replace 0 with NULL for pointers
|    Also remove a redundant semicolon.
|    Also had to rebase on upstream pull.
2019-06-02 16:28:20 +00:00
Warner Losh
b525355729 Merge from upstream at 4189ef5d from https://github.com/onetrueawk/awk.git
Note: this backs out a number of changes we've made to awk because
they aren't upstream, but are on the vendor branch. Those will be
reapplied. svn makes it needlessly difficult to know which ones, but
at least r315426, r301289, and maybe r301691, though there may be
others too. None of these are critical, so bisecting through this
point is safe for all but awk regression tests :).
2019-06-02 16:25:07 +00:00
Devin Teske
e0ff4751f0 Update awk(1) manual to state an exception to egrep(1)-like RE syntax
Reviewed by:	imp, jmg
MFC after:	3 days
Sponsored by:	Smule, Inc.
Differential Revision:	https://reviews.freebsd.org/D17739
2018-11-02 23:03:40 +00:00
Warner Losh
d12420d872 Don't display empty error context.
Context extraction didn't handle this case and showed uninitialized memory.

Obtained from: OpenBSD lib.c 1.21
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D12379
2017-09-24 05:04:06 +00:00
Warner Losh
8e537f8ae0 Fix %c for floating values that become 0 when coerced to int.
Obtained from: OpenBSD run.c 1.36 (From Jeremy Devenport)
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D12379
2017-09-24 05:04:02 +00:00
Warner Losh
547f34cace Fix uninitialized variable
echo | awk 'BEGIN {i=$1; print i}' prints a boatload of stack
garbage. NUL terminate the memory returned from malloc to prevent it.

Obtained from: OpenBSD run.c 1.40
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D12379
2017-09-24 05:03:57 +00:00
Warner Losh
73f7ff91b2 Implement gawk multiple-arg extension to and, or, and xor.
gawk allows multiple arguemnts to bit-wiste and, or and xor
functions. Implement an arbitrary number of arguments for these
functions. Also, use NULL in preference to 0 to match rest of file.

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D12361
2017-09-14 05:48:23 +00:00
Warner Losh
69679fc10f Bring in bit operation functions, ala gawk.
These are from OpenBSD:
>>> Extend awk with bitwise operations. This is an extension to the awk
>>> spec and documented as such, but comes in handy from time to time.
>>> The prototypes make it compatible with a similar GNU awk extension.
>>>
>>> ok millert@, enthusiasm from deraadt@

Edited to fix cut and paste in error messages, as well as
using tabs instead of spaces after #defines added.

Obtained From: OpenBSD awk.h 1.12, lex.c 1.10, run.c 1.29
Differential Revision: https://reviews.freebsd.org/D12361
Sponsored by: Netflix
2017-09-14 05:47:55 +00:00
Pedro F. Giffuni
6c10e0ba0b MFV r315425:
one-true-awk: have calloc(3) do the multiplication.

MFC after:	3 days
2017-03-16 21:32:05 +00:00
Andrey A. Chernov
cd3912b6be The bug:
$ echo x | awk '/[[:cntrl:]]/'
x

The NUL character in cntrl class truncates the pattern, and an empty
pattern matches anything. The patch skips NUL as a quick fix.

PR:     195792
Submitted by:   kdrakehp@zoho.com
Approved by:    bwk@cs.princeton.edu (the author)
MFC after:      3 days
2016-09-03 23:04:56 +00:00
Andrey A. Chernov
6c2a17d0b5 Back out non-collating [a-z] ranges.
Instead of changing the whole course to another POSIX-permitted way
for consistency and uniformity I decide to completely ignore missing
regex fucntionality and focus on fixing bugs in what we have now,
too many small obstacles we have choicing other way, counting ports.
Corresponding libc changes are backed out in r302824.
2016-07-14 09:31:52 +00:00
Andrey A. Chernov
1d148a7c3f After removing collation for [a-z] ranges in r302512, do it here too.
I'll try to keep the change very minimal to not touch contribed code much.
I'll send it upstream when it will be merged to main branches,
but we need the change right now here.
2016-07-13 10:01:31 +00:00
Pedro F. Giffuni
c8b6d1e472 Revert r301689 - one-true-awk: Avoid a NULL dereference.
I got this wrong and the coverity report doesn't match the NetBSD change,
which was thought for a different version.

The change wouldn't hurt but let's wait until upstream figures this out.
2016-06-08 19:39:44 +00:00
Pedro F. Giffuni
17ce5a9b90 one-true-awk: Avoid a NULL dereference.
CID:		270862
Obtained from:	NetBSD (CVS Rev. 1.8)
MFC after:	2 weeks
2016-06-08 19:24:48 +00:00
Pedro F. Giffuni
9051825205 MFV r300961:
one-true-awk: replace 0 with NULL for pointers

Also remove a redundant semicolon.
2016-06-03 21:23:11 +00:00
Pedro F. Giffuni
a4b2ac79e4 awk: Use random(3) instead of rand(3)
While none of them is considered even near to cryptographic
level, random(3) is a better random generator than rand(3).

Use random(3) for awk as is done in other systems.

Thanks to Chenguang Li for discussing this in the lists
and submitting the patch upstream.

PR:		193147
MFC after:	5 weeks
2014-09-19 18:24:02 +00:00
Xin LI
0840e960f9 MFV: one-true-awk 20121220.
MFC after:	1 month
2013-01-03 07:25:30 +00:00
Ruslan Ermilov
aa0da2e494 - Merged awk upstream that includes a fix for a bug exposed by kmod_syms.mk.
- Provide a build aid for those who already have a buggy awk(1) installed.

Approved by:	re (kib)
2011-08-11 10:29:10 +00:00
Ruslan Ermilov
d86a0988d2 Update to a 7-Aug-2011 release.
Approved by:	re (kib)
2011-08-09 12:54:43 +00:00
Ruslan Ermilov
b40501fb67 Update to a 6-May-2011 release (upstreamed some of our changes). 2011-05-06 14:21:46 +00:00
Ruslan Ermilov
1b11b78377 Update to a 1-May-2011 release (except for the isblank change). 2011-05-03 11:47:19 +00:00
Ruslan Ermilov
d98dd8e5f9 Apply patches directly to sources. Their effect is as follows:
- Make one-true-awk respect locale's collating order in [a-z]
  bracket expressions, until a more complete fix (like handing
  BREs) is ready.

- Don't require a space between -[fv] and its argument.
2010-01-10 08:02:07 +00:00
Ruslan Ermilov
91217c1c70 Update to a 26-Nov-2009 release. 2010-01-09 23:19:01 +00:00
Ruslan Ermilov
829089cc6f Clean up import. 2010-01-09 22:47:40 +00:00
Ruslan Ermilov
6023075d0d Flatten out vendor tree. 2010-01-09 22:31:11 +00:00
David E. O'Brien
168aca5df6 Document the bwk_20071023 import. 2007-10-25 12:38:34 +00:00
David E. O'Brien
d2f6e49220 Vendor import of bwk's 23-Oct-2007 release.
This includes fixes for FreeBSD PR's: bin/104795, bin/100443
2007-10-25 12:38:02 +00:00
David E. O'Brien
4afed873bc This commit was generated by cvs2svn to compensate for changes in r172958,
which included commits to RCS files with non-trunk default branches.
2007-10-25 12:38:02 +00:00
Rong-En Fan
a36454aac4 - Update for 2007/05/01 import.
Approved by:	delphij (mentor)
Nodded by:	ru
2007-06-05 15:34:40 +00:00
Rong-En Fan
addad6af5a Vendor import of bwk's 01-May-2007 release.
Approved by:	delphij (mentor)
Nodded by:	ru
Tested by:	make universe
2007-06-05 15:33:51 +00:00
Rong-En Fan
3aa1b8b946 This commit was generated by cvs2svn to compensate for changes in r170331,
which included commits to RCS files with non-trunk default branches.
2007-06-05 15:33:51 +00:00
Ruslan Ermilov
45c9b8cd6e Update for the 2005/04/24 import. 2005-05-16 19:19:32 +00:00
Ruslan Ermilov
c263f9bff0 Vendor import of bwk's 24-Apr-2005 release. 2005-05-16 19:11:36 +00:00
Ruslan Ermilov
e53d81968a This commit was generated by cvs2svn to compensate for changes in r146299,
which included commits to RCS files with non-trunk default branches.
2005-05-16 19:11:36 +00:00
Ruslan Ermilov
5bb0c94f9d Update for the 2004/02/07 import. 2004-02-08 21:39:18 +00:00
Ruslan Ermilov
62ebc626e6 Vendor import of bwk's 7-Feb-2004 release. 2004-02-08 21:32:21 +00:00
Ruslan Ermilov
43fb8a0b80 This commit was generated by cvs2svn to compensate for changes in r125601,
which included commits to RCS files with non-trunk default branches.
2004-02-08 21:32:21 +00:00
Ruslan Ermilov
63cf1d7ac8 Update for the 2003/07/31 import. 2004-02-07 16:46:05 +00:00
Ruslan Ermilov
2e454f23fa Fixes from 31-Jul-2003; make it 8-bit clean.
Forgotten by:	ru (for far too long)
2004-02-05 23:16:31 +00:00
Ruslan Ermilov
175f0360d3 This commit was generated by cvs2svn to compensate for changes in r125505,
which included commits to RCS files with non-trunk default branches.
2004-02-05 23:16:31 +00:00
Ruslan Ermilov
0560c735b9 Update for the 2003/07/29 import. 2003-07-30 06:50:31 +00:00
Ruslan Ermilov
88b8d48716 Vendor import of bwk's 29-Jul-2003 release. 2003-07-30 06:47:03 +00:00
Ruslan Ermilov
65259669d3 This commit was generated by cvs2svn to compensate for changes in r118194,
which included commits to RCS files with non-trunk default branches.
2003-07-30 06:47:03 +00:00