Commit Graph

97 Commits

Author SHA1 Message Date
kamil
2597218cc4 Add a missing check to handle correctly 0 * 0 in expr(1) 2018-06-27 17:23:36 +00:00
kamil
2b5da4d00d Improve the * operator handling in expr(1)
Fixes overflow detection in expressions INT * -UINT.

Detected with libFuzzer & UBSan.
2018-06-27 17:12:49 +00:00
christos
3ae7054da4 remove notreached 2018-06-14 02:46:56 +00:00
christos
721572cdb2 return to caller instead of exit(2) 2018-06-14 02:44:16 +00:00
kamil
2537a420e6 Detect properly overflow in expr(1) for 0 + INT 2018-06-13 17:35:15 +00:00
kamil
7806b47917 Rework perform_arith_op() in expr(1) to omit Undefined Behavior
The current implementation of operations - + * / % could cause Undefined
Behavior and in narrow cases (INT64_MIN / -1 and INT64_MIN % -1) SIGFPE
and crash duping core.

Detected with MKSANITIZER enabled for the Undefined Behavior variation:
# eval expr '4611686018427387904 + 4611686018427387904'
/public/src.git/bin/expr/expr.y:315:12: runtime error: signed integer overflow: 4611686018427387904 + 4611686018427387904 cannot be represented in type 'long'

All bin/t_expr ATF tests pass now in a sanitized userland.

Sponsored by <The NetBSD Foundation>
2018-06-12 18:12:18 +00:00
mrg
6d188dd0d7 convert HAVE_GCC handling to modern GCC release numbering:
- HAVE_GCC=5 is now the default (vs. HAVE_GCC=53 we've been using for
  GCC 5.4 and GCC 5.5.)
- remove some more GCC 4.8 code.  we don't support GCC 4 here.
- adjust set lists to gcc=5 from gcc=53.

add some basic HAVE_GCC=6 handling (totally unused so far.)
2018-02-02 01:02:39 +00:00
wiz
01869ca4d2 Remove workaround for ancient HTML generation code. 2017-07-03 21:28:48 +00:00
sevan
51fe790c4c Drop main() prototype. 2016-09-05 01:00:07 +00:00
sevan
03fb25d442 Mark email addresses as mailto links, heads up by Sascha Wildner.
Move email addresses to same line as author name.
Do not split the third author entry on to a new line.
Public domain is not licensed by definition, heads up by Robert Elz.
2016-08-23 20:34:23 +00:00
sevan
9e84015020 Instruction to not split the line needs to be stated separately. 2016-08-23 03:21:16 +00:00
sevan
0f2a09011f Add HISTORY section
Credit author of initial implementation in AUTHORS section
Bump date
Remove contraction highlighted by textproc/igor
2016-08-23 02:58:45 +00:00
mrg
6d27b0e86e for GCC 5.3 pass -fwrapv as this relies upon well-defined integer overflow. 2016-04-01 08:19:31 +00:00
wiz
8630b9004f Improvements: wording, punctuation, macro usage.
From patch by Bug Hunting.
2012-08-12 17:27:04 +00:00
jdf
4197d2d493 Remove an unnecessary space in the manpage. Patch provided by Bug Hunting. 2012-05-09 22:29:06 +00:00
joerg
66dd2755f5 Add __printflike attribution to use vprintf and friends with an argument
as format string.
2012-03-15 02:02:20 +00:00
joerg
370cd318b5 Mark yyerror as dead. 2011-08-25 01:11:47 +00:00
dholland
9653d2d60a minor usage nit 2011-03-23 18:10:25 +00:00
joerg
52bf796fd6 Explicitly quote | and : meant as separate operator. Kill trailing
whitespace. Don't use \Z' with obscure character entity. Reorder sections
to canonical order.
2010-05-24 00:29:30 +00:00
joerg
5792116078 Revert for now, pending discussion of how expr should behave in the case
of pre-POSIX expressions.
2009-01-20 14:22:37 +00:00
joerg
14d25567b4 SUS says that expr must support "--" to prevent interpretation of
negative numbers as options.
2009-01-20 13:04:55 +00:00
martin
8eba9df29f Normalize TNF license, move to 2 clause. 2008-04-30 13:39:13 +00:00
martin
11a6dbe728 Convert TNF licenses to new 2 clause variant 2008-04-30 13:10:46 +00:00
rumble
2174dda221 Handle asprintf failing to allocate. 2006-03-17 14:43:11 +00:00
lukem
5760da6393 appease gcc -Wuninitialized 2005-06-01 15:12:18 +00:00
wiz
6af689d38b Grammar improvement by Patrick Welche. 2004-04-23 13:28:58 +00:00
wiz
a423ef4af0 Add some articles; use No instead of Li in one place
(more correct, see e.g. PostScript output); bump date for previous.
2004-04-20 20:47:47 +00:00
jdolecek
c92704dc53 add support for 'length' keyword, for compatibility with GNU expr 2004-04-20 19:44:51 +00:00
jdolecek
217903eeea explicitly use REG_BASIC when calling regcomp(3), instead of 0 2004-03-20 08:45:05 +00:00
wiz
00c8cf496c Add some articles. 2003-12-21 11:18:25 +00:00
jdolecek
83f8b02df2 add a note explaining empty string matching via :
this adresses bin/23810 by VaX#n8

bump date and update copyright
2003-12-21 10:02:46 +00:00
perry
83237da0b1 spelling errors, some from Igor Sobrado in PR 19670 2003-03-29 18:25:22 +00:00
grant
a15c6f031f 'NetBSD.org' 2003-02-14 16:17:30 +00:00
wiz
14dfaa4b03 New policy: New sentences start on a new line.
Patches by Robert Elz <kre at munnari oz au>, with minimal changes by me.
2002-09-25 15:18:36 +00:00
pooka
2b1fe1903a rewritten in NetBSD 1.6 -> rewritten for NetBSD 1.6 2002-02-19 21:14:45 +00:00
ross
dc5571b22e Generate <>& symbolically. I'm avoiding .../dist/... directories for now. 2002-02-08 01:21:55 +00:00
wiz
e0ab876efe Use standard headers, sort sections. 2001-12-20 20:05:12 +00:00
wiz
880b4d21b9 Quote `:' correctly. 2001-10-18 11:00:03 +00:00
wiz
7a64806dbc Use {g,s}etprogname, and some other KNF stuff. Patch by Petri Koistinen. 2001-09-16 13:42:10 +00:00
jdolecek
3b932d2fe1 Fix the operator precedence list to match reality. Operators were incorrectly
grouped there.
2001-05-07 10:14:43 +00:00
jmc
64e6a11adc Various cleanups/fixes.
Change the add/subtract overflow checks to use an unsigned to do the op
and then cast back into the signed var to check the signs.

Make multiply shortcut on either right or left being 0.
Make multiply's overflow test not fail on simple cases like 1 * -1
Make the multiple overflow test pass all the regress tests.
2001-05-06 06:20:39 +00:00
jmc
a7755cce7c Various changes to fix bugs in PR bin/12838.
Make sure all precendence is spelled out correctly (comparison does not
have the same level as the arithmetic operators..)
Break the arithemtic operators into 2 classes (+- are lower than */%)
Restructure the arithmetic code into a function either class above can call.
Finally, add a whole suite of regression tests (checked in separately) which
the previous code failed on 3 of them.
2001-05-05 06:57:57 +00:00
simonb
6f6fe2f3ad Spell occurred correctly. 2001-04-25 02:33:08 +00:00
christos
a66a2e0ad0 remove redundant declaration of yyparse 2001-02-04 19:51:14 +00:00
jdolecek
9ad5bf10de list parenthesis usage similar way as other operators
document operator precedence
rename section BUGS to COMPATIBILITY, add paragraph about -- handling
2000-10-30 16:20:12 +00:00
jdolecek
5888f4d21c add a hack to properly handle '--' as first argument -
it's ignored if it would cause syntax error, otherwise treated as common
string; this is so that both 'expr -- : .' and 'expr -- foo : .' works
This addresses standards/11230 by Ben Harris.

while here, make all global variables but main() static, use const more
2000-10-30 14:55:02 +00:00
thorpej
401ea1afda The "&" operator has a higer precedence than "|". 2000-10-29 17:16:02 +00:00
jdolecek
c13c5901f2 also credit J.T. Conklin in copyright message 2000-10-27 21:40:02 +00:00
jdolecek
fb2525abf5 fix operator precedence - | or & have lower priority than
arithmetic operations, compare, or :
This should fix bin/11318 by Love <lha@stacken.kth.se>
2000-10-26 23:10:21 +00:00
jdolecek
fd6eeb2e1d in regexp handling code, fix the format passed to asprintf() to be
actually in intended form - use "%.*s" and not incorrect "%*s"

Bug found by Launey Thomas <ljt@alum.mit.edu> and reported in private e-mail.
2000-09-29 17:49:21 +00:00