mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-17 23:09:09 +02:00
* Fix overflows in intstrtodate (bug ID 32098)
git-svn-id: trunk@36687 -
This commit is contained in:
parent
d5c8fe7455
commit
e9a3a807d0
@ -368,11 +368,11 @@ end;
|
|||||||
|
|
||||||
var
|
var
|
||||||
df:string;
|
df:string;
|
||||||
d,m,y,ly:word;
|
d,m,y,ly:integer;
|
||||||
n,i:longint;
|
n,i:longint;
|
||||||
c:word;
|
c:word;
|
||||||
dp,mp,yp,which : Byte;
|
dp,mp,yp,which : Byte;
|
||||||
s1:string[4];
|
s1:string;
|
||||||
values:array[0..3] of longint;
|
values:array[0..3] of longint;
|
||||||
LocalTime:tsystemtime;
|
LocalTime:tsystemtime;
|
||||||
YearMoreThenTwoDigits : boolean;
|
YearMoreThenTwoDigits : boolean;
|
||||||
@ -446,6 +446,7 @@ begin
|
|||||||
// Check if the year has more then two digits (if n=yp, then we are evaluating the year.)
|
// Check if the year has more then two digits (if n=yp, then we are evaluating the year.)
|
||||||
if (n=yp) and (length(s1)>2) then YearMoreThenTwoDigits := True;
|
if (n=yp) and (length(s1)>2) then YearMoreThenTwoDigits := True;
|
||||||
val(s1, values[n], c);
|
val(s1, values[n], c);
|
||||||
|
// Writeln(s1,'->',values[n]);
|
||||||
if c<>0 then
|
if c<>0 then
|
||||||
begin
|
begin
|
||||||
FixErrorMsg(SInvalidDateFormat,s);
|
FixErrorMsg(SInvalidDateFormat,s);
|
||||||
@ -467,6 +468,12 @@ begin
|
|||||||
// Fill in values.
|
// Fill in values.
|
||||||
getLocalTime(LocalTime);
|
getLocalTime(LocalTime);
|
||||||
ly := LocalTime.Year;
|
ly := LocalTime.Year;
|
||||||
|
for I:=1 to 3 do
|
||||||
|
if values[i]>high(Word) then
|
||||||
|
begin
|
||||||
|
errormsg:='Invalid date';
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
If N=3 then
|
If N=3 then
|
||||||
begin
|
begin
|
||||||
y:=values[yp];
|
y:=values[yp];
|
||||||
@ -500,6 +507,7 @@ begin
|
|||||||
if (defs.TwoDigitYearCenturyWindow > 0) and (Y < ly) then
|
if (defs.TwoDigitYearCenturyWindow > 0) and (Y < ly) then
|
||||||
Inc(Y, 100);
|
Inc(Y, 100);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if not TryEncodeDate(y, m, d, result) then
|
if not TryEncodeDate(y, m, d, result) then
|
||||||
errormsg:='Invalid date';
|
errormsg:='Invalid date';
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user