From f9297e0574306e120460937410f5a34893aea79d Mon Sep 17 00:00:00 2001 From: millert Date: Tue, 2 Nov 2021 15:29:41 +0000 Subject: [PATCH] Update awk to October 12, 2021 version. Fixes a decision bug with trailing stuff in lib.c:is_valid_number. All other fixes were already present. --- usr.bin/awk/FIXES | 32 +++++++++++++++++++++++++++++++- usr.bin/awk/README.md | 14 +++++++------- usr.bin/awk/lib.c | 11 +++++++++-- usr.bin/awk/main.c | 4 ++-- usr.bin/awk/tran.c | 6 +++--- 5 files changed, 52 insertions(+), 15 deletions(-) diff --git a/usr.bin/awk/FIXES b/usr.bin/awk/FIXES index 05f47946793..4cffc444ad9 100644 --- a/usr.bin/awk/FIXES +++ b/usr.bin/awk/FIXES @@ -1,4 +1,4 @@ -/* $OpenBSD: FIXES,v 1.40 2020/12/18 21:36:24 millert Exp $ */ +/* $OpenBSD: FIXES,v 1.41 2021/11/02 15:29:41 millert Exp $ */ /**************************************************************** Copyright (C) Lucent Technologies 1997 All Rights Reserved @@ -26,6 +26,36 @@ THIS SOFTWARE. This file lists all bug fixes, changes, etc., made since the AWK book was sent to the printers in August, 1987. +Oct 12, 2021: + The fix for #83 changed the code to insert 2 chars, but the + call to adjbuf just above it only allows for 1 char. This can + cause a heap buffer overflow. + +July 27, 2021: + As per IEEE Std 1003.1-2008, -F "str" is now consistent with + -v FS="str" when str is null. Thanks to Warner Losh. + +July 24, 2021: + Fix readrec's definition of a record. This fixes an issue + with NetBSD's RS regular expression support that can cause + an infinite read loop. Thanks to Miguel Pineiro Jr. + + Fix regular expression RS ^-anchoring. RS ^-anchoring needs to + know if it is reading the first record of a file. This change + restores a missing line that was overlooked when porting NetBSD's + RS regex functionality. Thanks to Miguel Pineiro Jr. + + Fix size computation in replace_repeat() for special case + REPEAT_WITH_Q. Thanks to Todd C. Miller. + +February 15, 2021: + Small fix so that awk will compile again with g++. Thanks to + Arnold Robbins. + +January 06, 2021: + Fix a decision bug with trailing stuff in lib.c:is_valid_number + after recent changes. Thanks to Ozan Yigit. + December 18, 2020: Fix problems converting inf and NaN values in lib.c:is_valid_number. Enhance number to string conversion to do the right thing for diff --git a/usr.bin/awk/README.md b/usr.bin/awk/README.md index 655006e49fc..f90de30cd09 100644 --- a/usr.bin/awk/README.md +++ b/usr.bin/awk/README.md @@ -1,4 +1,4 @@ -$OpenBSD: README.md,v 1.4 2020/12/09 20:00:11 millert Exp $ +$OpenBSD: README.md,v 1.5 2021/11/02 15:29:41 millert Exp $ # The One True Awk @@ -109,17 +109,17 @@ astonishly slow. If `awk` seems slow, you might try fixing that. More generally, turning on optimization can significantly improve `awk`'s speed, perhaps by 1/3 for highest levels. +## A Note About Releases + +We don't do releases. + ## A Note About Maintenance -NOTICE! Maintenance of this program is on a ``best effort'' +NOTICE! Maintenance of this program is on a ''best effort'' basis. We try to get to issues and pull requests as quickly as we can. Unfortunately, however, keeping this program going is not at the top of our priority list. -_If_ you (yes, you!) are interested in taking over active maintenance of -`awk`, please open an issue to indicate that fact, and give us a little bit of -your background and some idea of your plans and dreams. Thanks! - #### Last Updated -Tue Oct 13 20:00:09 IDT 2020 +Sat Jul 25 14:00:07 EDT 2021 diff --git a/usr.bin/awk/lib.c b/usr.bin/awk/lib.c index cd84399c9b0..752b66d9a8d 100644 --- a/usr.bin/awk/lib.c +++ b/usr.bin/awk/lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lib.c,v 1.46 2021/06/10 21:01:43 millert Exp $ */ +/* $OpenBSD: lib.c,v 1.47 2021/11/02 15:29:41 millert Exp $ */ /**************************************************************** Copyright (C) Lucent Technologies 1997 All Rights Reserved @@ -825,10 +825,17 @@ convert: if (result != NULL) *result = r; - retval = (isspace((uschar)*ep) || *ep == '\0' || trailing_stuff_ok); + /* + * check for trailing stuff + */ + while (isspace((uschar)*ep)) + ep++; if (no_trailing != NULL) *no_trailing = (*ep == '\0'); + // return true if found the end, or trailing stuff is allowed + retval = *ep == '\0' || trailing_stuff_ok; + return retval; } diff --git a/usr.bin/awk/main.c b/usr.bin/awk/main.c index 61b011b4128..c3ec30b5b41 100644 --- a/usr.bin/awk/main.c +++ b/usr.bin/awk/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.48 2021/07/27 18:28:19 millert Exp $ */ +/* $OpenBSD: main.c,v 1.49 2021/11/02 15:29:41 millert Exp $ */ /**************************************************************** Copyright (C) Lucent Technologies 1997 All Rights Reserved @@ -23,7 +23,7 @@ ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ****************************************************************/ -const char *version = "version 20201218"; +const char *version = "version 20211012"; #define DEBUG #include diff --git a/usr.bin/awk/tran.c b/usr.bin/awk/tran.c index 41a0faa4a4d..41acfc0fa39 100644 --- a/usr.bin/awk/tran.c +++ b/usr.bin/awk/tran.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tran.c,v 1.33 2020/12/18 21:36:24 millert Exp $ */ +/* $OpenBSD: tran.c,v 1.34 2021/11/02 15:29:41 millert Exp $ */ /**************************************************************** Copyright (C) Lucent Technologies 1997 All Rights Reserved @@ -419,7 +419,7 @@ Awkfloat getfval(Cell *vp) /* get float val of a Cell */ return(vp->fval); } -static char *get_inf_nan(double d) +static const char *get_inf_nan(double d) { if (isinf(d)) { return (d < 0 ? "-inf" : "+inf"); @@ -433,7 +433,7 @@ static char *get_str_val(Cell *vp, char **fmt) /* get string val of a Cel { int n; double dtemp; - char *p; + const char *p; if ((vp->tval & (NUM | STR)) == 0) funnyvar(vp, "read value of"); -- 2.20.1