Date: Mon, 21 Sep 2020 19:03:07 +0000 (UTC) From: Alex Richardson <arichardson@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r365968 - head/contrib/one-true-awk Message-ID: <202009211903.08LJ37g8030704@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: arichardson Date: Mon Sep 21 19:03:07 2020 New Revision: 365968 URL: https://svnweb.freebsd.org/changeset/base/365968 Log: 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 https://github.com/onetrueawk/awk/commit/cbf924342b63a095a4c6842280c3085b1b63ae45 Found by: CHERI (with subobject bounds enabled) Obtained from: CheriBSD Reviewed By: imp Differential Revision: https://reviews.freebsd.org/D26509 Modified: head/contrib/one-true-awk/awk.h head/contrib/one-true-awk/b.c Modified: head/contrib/one-true-awk/awk.h ============================================================================== --- head/contrib/one-true-awk/awk.h Mon Sep 21 18:34:13 2020 (r365967) +++ head/contrib/one-true-awk/awk.h Mon Sep 21 19:03:07 2020 (r365968) @@ -218,6 +218,8 @@ extern int pairstack[], paircnt; #define NCHARS (256+3) /* 256 handles 8-bit chars; 128 does 7-bit */ /* watch out in match(), etc. */ #define NSTATES 32 +#define HAT (NCHARS+2) /* matches ^ in regular expr */ + /* NCHARS is 2**n */ typedef struct rrow { long ltype; /* long avoids pointer warnings on 64-bit */ @@ -230,7 +232,7 @@ typedef struct rrow { } rrow; typedef struct fa { - uschar gototab[NSTATES][NCHARS]; + uschar gototab[NSTATES][HAT + 1]; uschar out[NSTATES]; uschar *restr; int *posns[NSTATES]; Modified: head/contrib/one-true-awk/b.c ============================================================================== --- head/contrib/one-true-awk/b.c Mon Sep 21 18:34:13 2020 (r365967) +++ head/contrib/one-true-awk/b.c Mon Sep 21 19:03:07 2020 (r365968) @@ -37,8 +37,6 @@ __FBSDID("$FreeBSD$"); #include "awk.h" #include "ytab.h" -#define HAT (NCHARS+2) /* matches ^ in regular expr */ - /* NCHARS is 2**n */ #define MAXLIN 22 #define type(v) (v)->nobj /* badly overloaded here */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202009211903.08LJ37g8030704>