Commit Graph

21 Commits

Author SHA1 Message Date
Arnold D. Robbins
3b42cfaf73 Make it compile with g++. 2020-10-13 20:52:43 +03:00
Arnold D. Robbins
07f0438423 Move exclusively to bison as parser generator. 2020-07-30 17:12:45 +03:00
enh-google
7b245a0266
Fix hwasan global overflow. (#76)
* Fix hwasan global overflow.

Crash found with https://source.android.com/devices/tech/debug/hwasan
but also detectable by regular ASan. Here's an ASan crash:

==215690==ERROR: AddressSanitizer: global-buffer-overflow on address
  0x55d90f8da140 at pc 0x55d90f8b7503 bp 0x7ffd3dae6100 sp 0x7ffd3dae60f8
  READ of size 4 at 0x55d90f8da140 thread T0
    #0 0x55d90f8b7502 in word /tmp/awk/lex.c:496
    #1 0x55d90f8b939f in yylex /tmp/awk/lex.c:191
    #2 0x55d90f894ab9 in yyparse /tmp/awk/awkgram.tab.c:2366
    #3 0x55d90f89edc2 in main /tmp/awk/main.c:216
    #4 0x7ff263a78bba in __libc_start_main ../csu/libc-start.c:308
    #5 0x55d90f8945a9 in _start (/tmp/awk/a.out+0x115a9)

0x55d90f8da141 is located 0 bytes to the right of global variable
'infunc' defined in 'awkgram.y:35:6' (0x55d90f8da140) of size 1

SUMMARY: AddressSanitizer: global-buffer-overflow /tmp/awk/lex.c:496 in word
Shadow bytes around the buggy address:
  0x0abba1f133d0: f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9
  0x0abba1f133e0: f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9
  0x0abba1f133f0: f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9
  0x0abba1f13400: f9 f9 f9 f9 00 00 00 00 00 00 00 00 00 00 00 00
  0x0abba1f13410: 00 f9 f9 f9 f9 f9 f9 f9 00 f9 f9 f9 f9 f9 f9 f9
=>0x0abba1f13420: 04 f9 f9 f9 f9 f9 f9 f9[01]f9 f9 f9 f9 f9 f9 f9
  0x0abba1f13430: 00 f9 f9 f9 f9 f9 f9 f9 00 f9 f9 f9 f9 f9 f9 f9
  0x0abba1f13440: 00 00 00 00 00 f9 f9 f9 f9 f9 f9 f9 04 f9 f9 f9
  0x0abba1f13450: f9 f9 f9 f9 00 f9 f9 f9 f9 f9 f9 f9 04 f9 f9 f9
  0x0abba1f13460: f9 f9 f9 f9 04 f9 f9 f9 f9 f9 f9 f9 04 f9 f9 f9
  0x0abba1f13470: f9 f9 f9 f9 00 f9 f9 f9 f9 f9 f9 f9 00 f9 f9 f9

And here's the stack trace from hwasan:

  Stack Trace:
  RELADDR           FUNCTION         FILE:LINE
  00000000000168d4  word             external/one-true-awk/lex.c:496:18
  000000000002d1ec  yyparse          y.tab.c:2460:16
  000000000001c82c  main             external/one-true-awk/main.c:179:2
  00000000000b41a0  __libc_init      bionic/libc/bionic/libc_init_dynamic.cpp:151:8

As it says, we're doing a 4-byte read from a 1-byte global.

`infunc` is declared as an int but defined as a bool.

Signed-off-by: Evgenii Stepanov <eugenis@google.com>

* Add ASan cflags to makefile.

They're not used by default, but this way they're easily to hand next
time they're wanted.
2020-02-28 13:18:29 +02:00
zoulasc
94e4c04561
argument parsing cleanups, dynamic program file allocation, fpe error enhancement. (#72)
* - enhance fpe handler to print the error type
- cleanup argument parsing
- dynamically allocate program filename array

* bison uses enums now, not #define's, make it work with that.

* We need to use either the enums or the defines but not both. This
is because bison -y will create both enums and #defines, while bison
without -y produces only the enums, and byacc produces just #defines.

* fix indentation

* Set the tokentype when we have a match in the scan, and reset it later
when we decide that the match was bad. Fixes nbyacc.

* - don't use pattern rules for portability
- try to move both flavors of generated names for portability

* Amend tests for the new error messages
2020-02-18 21:20:27 +02:00
Arnold D. Robbins
8b92a4abcb Add 'distclean' target to makefile. 2019-10-24 09:44:00 -04:00
Arnold D. Robbins
961eec1fb5 Additional fixes after merge of PR 53. 2019-10-24 09:42:51 -04:00
Arnold D. Robbins
795a06b58c Remove trailing whitespace on lines in all files. 2019-07-28 05:51:52 -06:00
Arnold D. Robbins
cebda366a9 Improve cleanup of test directory upon 'make clean'. 2019-07-26 12:57:48 +03:00
Arnold D. Robbins
ab911ab204 Update makefile, mainly to clean up testdir. 2019-06-24 01:10:24 -06:00
Arnold D. Robbins
55edb1b1dd Simplify cross-compiling change. Update FIXES. 2019-03-12 21:54:57 +02:00
nee-san
c83d943830 Fix cross-build (#34)
* Fix cross-build

Fixes in make file to support cross-build because maketab is a host tool and should be compiled with host compiler

* some
2019-03-12 21:52:17 +02:00
Elliott Hughes
cc165f4be9 maketab: support build systems with read-only source.
If your generated files are considered outputs that live elsewhere, you
need a way to tell maketab where ytab.h actually is.

Specifically, I'm trying to avoid checking in generated files in
Android's AOSP tree's copy of one-true-awk.
2019-01-29 17:20:00 -08:00
Christoph Junghans
e4bb3bcbf0 fixed parallel build
Signed-off-by: Christoph Junghans <junghans@gentoo.org>
2018-12-30 09:04:34 -07:00
Brian Kernighan
e8c280034f fix maketab non-bug 2018-10-25 13:28:54 -04:00
Adam Sampson
9a4aa89176 Fix ytab.[ch] dependencies to allow parallel make.
The old ytab.o rule produced ytab.c and ytab.h too, but this wasn't
visible as dependencies, so make -j would fail. Make this explicit, and
use the implicit .c.o rule rather than writing out the $(CC) command.
2018-08-27 20:28:29 +01:00
Adam Sampson
837b8da3a5 Fix comment syntax for pmake.
GNU make is happy with leading tabs before a comment, but pmake says
"Unassociated shell command".
2018-08-27 20:27:34 +01:00
Brian Kernighan
0f4e1ba922 added Arnold's fixes, updates to awktest.tar 2018-08-24 09:09:59 -04:00
Arnold D. Robbins
32093f5bbf Fix multiple long-standing bugs, improve test suite. 2018-08-22 20:40:26 +03:00
Brian Kernighan
ba7569c255 FIXES, makefile, REGRESS to smooth out base for Arnold 2018-08-16 09:41:13 -04:00
Brian Kernighan
3ed9e245db set baseline so Arnold can send pull request 2018-08-15 10:45:03 -04:00
Brian Kernighan
87b94932e6 initial commit for github 2012-12-22 10:35:39 -05:00