Commit Graph

14 Commits

Author SHA1 Message Date
Jørgen Kvalsvik
8e4e9b15d8 ReadValueToken correctly parses numbers
Changes the implementation of numbers parsing from std::atoi/f to
std::strtod/l. These support setting the optional end-of-string pointer
which are used to determine if a parsing was successful or not. This has
the nice side effect of *greatly* simplifying the logic, at the expense
of some C-style details.

Tests added to verify that the different edge cases are handled
properly.
2016-04-01 10:13:37 +02:00
Jørgen Kvalsvik
aa064a9050 Fix buffer overflow vulnerability
An attacker using very long decimal integers as input could trigger a
buffer overflow write during int/double parsing.

The vulnerability has been fixed and raw buffer boundaries are checked.
Additionally, integer buffer size is determined by platform 'int' width.
'double' uses a heuristic to support both pure decimal formats (up to 64
characters long) and float formats.
2016-03-15 16:42:02 +01:00
Atgeirr Flø Rasmussen
f23af386cf Add missing include, remove unused function. 2016-03-14 13:22:22 +01:00
Jørgen Kvalsvik
28eb195ac3 readValueToken< double > split into fast/slow path.
readValueToken spent almost half its time dealing with weirdly formed or
broken floats. Now has a shorter path that can early return a
successfully parsed float and only do slow handling of cases that need
it (notably zero, fortran style exponent and errors).
2016-03-14 08:29:54 +01:00
Jørgen Kvalsvik
93b7c0739b Replace boost::lexical_cast<> with std functions
The boost provided lexical cast are inefficient and is shown to be a
slowdown in the inner loop. Replaces them with std::atoi/std::atof and
some simple correctness checking.
2016-03-14 08:29:53 +01:00
Jørgen Kvalsvik
798084676a RawRecord uses string_view internally
Modifies RawRecord to internally use string_view instead of copies of
the substrings. This *vastly* reduces copying in the processing of each
record and subsequently improves performance. Reduces total memory usage
in Deck construction.
2016-03-14 08:29:53 +01:00
Jørgen Kvalsvik
d0d4a74d31 Moves readValueToken implementation to source file
The templated readValueToken has been moved to source file, and uses
explicit instantiation and linking. The deprecated float specialisation
has been removed.
2016-03-04 18:27:44 +01:00
Andreas Lauser
435e6aa6c5 extend "StarToken" class
that's because not every token which contains a star represents an
repetion, e.g.

'PROD*'

and

'123*456'

(with the quotes) are strings...
2014-09-15 12:27:28 +02:00
Kristian Flikka
697c273c19 OPM-94: Removed specialized int,double,string implementations, one generic covers the same 2014-07-10 13:24:49 +02:00
Atle Haugan
344d02ad1c Add support for wildcard in WCONPROD and WCONINJE keywords. 2014-05-06 09:54:37 +02:00
Kristian Flikka
ce692159c9 Trimming right side of each read line, to avoid line ending problems.
Removed C style parsing of numbers, using boost::lexical_cast instead.
2013-12-03 10:15:22 +01:00
Joakim Hove
dabfdb922b Added loose function tokenCOntainsStar to StarToken.cpp 2013-10-14 21:27:20 +02:00
Joakim Hove
a7078ba687 Implemented StarToken specializations in cpp file 2013-10-14 21:05:10 +02:00
Joakim Hove
ccae60777d Ensure that StarToken() will throw for missing multiplier 2013-10-14 17:49:07 +02:00