Merge lp:~paul-lucas/zorba/bug-1085408 into lp:zorba

Proposed by Paul J. Lucas
Status: Merged
Approved by: Nicolae Brinza
Approved revision: 11374
Merged at revision: 11375
Proposed branch: lp:~paul-lucas/zorba/bug-1085408
Merge into: lp:zorba
Diff against target: 71 lines (+28/-19)
2 files modified
ChangeLog (+1/-0)
src/zorbatypes/datetime/parse.cpp (+27/-19)
To merge this branch: bzr merge lp:~paul-lucas/zorba/bug-1085408
Reviewer Review Type Date Requested Status
Nicolae Brinza Approve
Paul J. Lucas Approve
Review via email: mp+159063@code.launchpad.net

Commit message

Fixed signed integer overflow bug.

Description of the change

Fixed signed integer overflow bug.

To post a comment you must log in.
Revision history for this message
Paul J. Lucas (paul-lucas) :
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

The attempt to merge lp:~paul-lucas/zorba/bug-1085408 into lp:zorba failed. Below is the output from the failed tests.

CMake Error at /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake:275 (message):
  Validation queue job bug-1085408-2013-04-16T02-33-43.66Z is finished. The
  final status was:

  1 tests did not succeed - changes not commited.

Error in read script: /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job bug-1085408-2013-04-16T06-25-41.622Z is finished. The final status was:

All tests succeeded!

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Voting does not meet specified criteria. Required: Approve > 1, Disapprove < 1, Needs Fixing < 1, Pending < 1, Needs Information < 1, Resubmit < 1. Got: 1 Approve.

Revision history for this message
Nicolae Brinza (nbrinza) :
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job bug-1085408-2013-04-16T13-12-02.236Z is finished. The final status was:

All tests succeeded!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ChangeLog'
2--- ChangeLog 2013-04-11 18:13:48 +0000
3+++ ChangeLog 2013-04-16 06:08:26 +0000
4@@ -43,6 +43,7 @@
5 * Fixed bug #1147518 (fn:round-half-to-even (at least 11 failures))
6 * Fixed bug #1114228 (unrecognized options in the XQuery namespace now raise an error)
7 * Fixed bug #1124273 (xqdoc crash because of annotation literals)
8+ * Fixed bug #1085408 (xs:date(): casting large year values)
9 * Fixed bug #867027 (XQST0059 error messages inconsistent)
10 * Fixed bug #1095889 (Improve error message for xml-parsing error).
11 * Fixed bug #1123163 (fn:format-integer failures)
12
13=== modified file 'src/zorbatypes/datetime/parse.cpp'
14--- src/zorbatypes/datetime/parse.cpp 2013-04-05 09:48:19 +0000
15+++ src/zorbatypes/datetime/parse.cpp 2013-04-16 06:08:26 +0000
16@@ -53,29 +53,37 @@
17 long max_digits,
18 size_t delta)
19 {
20- int tmp_result = 0; // We have to downgrade the precision here from long to int so that some FOTS tests will throw a FOTD0001 date/time overflow.
21- // When alternative correct results will be available, this precision downgrading can be removed.
22- long digits = 0;
23-
24- if (position + delta >= len)
25- return 1;
26-
27- if (str[position+delta] < '0' || str[position+delta] > '9')
28- return 1;
29-
30- while ( position + delta < len && ascii::is_digit( str[position+delta] ) )
31- {
32- tmp_result = 10 * tmp_result + str[position + delta] - '0';
33- position++;
34- digits++;
35-
36- if (tmp_result < 0) // we've had an overflow
37- return 2;
38+ if ( position + delta >= len )
39+ return 1;
40+
41+ //
42+ // We have to downgrade the precision here from sizeof(long) to sizeof(int)
43+ // so that some FOTS tests will throw a FOTD0001 date/time overflow. When
44+ // alternative correct results are available, this precision downgrading can
45+ // be removed.
46+ //
47+ int tmp_result = 0;
48+
49+ int digits = 0;
50+
51+ if ( !ascii::is_digit( str[position+delta] ) )
52+ return 1;
53+
54+ while ( position + delta < len && ascii::is_digit( str[position+delta] ) ) {
55+ int const tmp_prev = tmp_result;
56+ tmp_result *= 10;
57+ // See <http://stackoverflow.com/q/199333/99089>
58+ if ( tmp_result / 10 != tmp_prev )
59+ return 2; // overflow
60+ tmp_result += str[position + delta] - '0';
61+ if ( tmp_result < tmp_prev )
62+ return 2; // overflow
63+ ++digits;
64+ ++position;
65 }
66
67 if (min_digits >= 0 && digits < min_digits)
68 return 1;
69-
70 if (max_digits >= 0 && digits > max_digits)
71 return 1;
72

Subscribers

People subscribed via source and target branches