From: millert Date: Sat, 9 Sep 2023 18:59:43 +0000 (+0000) Subject: Update awk to Dec 15, 2022 version. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=3e3c92c2dca3e3bcb38ad489efb32f2242ea7c29;p=openbsd Update awk to Dec 15, 2022 version. Force hex escapes in strings to be no more than two characters, as they already are in regular expressions. This brings internal consistency, as well as consistency with gawk. --- diff --git a/usr.bin/awk/FIXES b/usr.bin/awk/FIXES index fdf782e6295..53c78410647 100644 --- a/usr.bin/awk/FIXES +++ b/usr.bin/awk/FIXES @@ -25,6 +25,12 @@ THIS SOFTWARE. This file lists all bug fixes, changes, etc., made since the AWK book was sent to the printers in August 1987. +Dec 15, 2022: + Force hex escapes in strings to be no more than two characters, + as they already are in regular expressions. This brings internal + consistency, as well as consistency with gawk. Thanks to + Arnold Robbins. + Sep 12, 2022: adjbuf minlen error (cannot be 0) in cat, resulting in NULL pbuf. discovered by todd miller. also use-after-free issue with diff --git a/usr.bin/awk/lex.c b/usr.bin/awk/lex.c index 39c9a05abf1..213f5d0a9e7 100644 --- a/usr.bin/awk/lex.c +++ b/usr.bin/awk/lex.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lex.c,v 1.28 2022/09/01 15:21:28 millert Exp $ */ +/* $OpenBSD: lex.c,v 1.29 2023/09/09 18:59:43 millert Exp $ */ /**************************************************************** Copyright (C) Lucent Technologies 1997 All Rights Reserved @@ -427,19 +427,28 @@ int string(void) break; case 'x': /* hex \x0-9a-fA-F + */ - { char xbuf[100], *px; - for (px = xbuf; (c = input()) != 0 && px-xbuf < 100-2; ) { - if (isdigit(c) - || (c >= 'a' && c <= 'f') - || (c >= 'A' && c <= 'F')) - *px++ = c; - else + { + int i; + + n = 0; + for (i = 1; i <= 2; i++) { + c = input(); + if (c == 0) + break; + if (isxdigit(c)) { + c = tolower(c); + n *= 16; + if (isdigit(c)) + n += (c - '0'); + else + n += 10 + (c - 'a'); + } else break; } - *px = 0; - unput(c); - sscanf(xbuf, "%x", (unsigned int *) &n); - *bp++ = n; + if (n) + *bp++ = n; + else + unput(c); break; } diff --git a/usr.bin/awk/main.c b/usr.bin/awk/main.c index 4b057660c1f..ccd557c1ef2 100644 --- a/usr.bin/awk/main.c +++ b/usr.bin/awk/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.56 2022/09/21 01:42:58 millert Exp $ */ +/* $OpenBSD: main.c,v 1.57 2023/09/09 18:59:43 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 20220912"; +const char *version = "version 20221215"; #define DEBUG #include