Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
814acfcc
Commit
814acfcc
authored
Dec 01, 2005
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check for overflow in strtol() while parsing datetime inputs.
Michael Fuhr.
parent
cab40818
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
1 deletion
+33
-1
src/backend/utils/adt/datetime.c
src/backend/utils/adt/datetime.c
+33
-1
No files found.
src/backend/utils/adt/datetime.c
View file @
814acfcc
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/datetime.c,v 1.16
1 2005/11/22 18:17:22 momjian
Exp $
* $PostgreSQL: pgsql/src/backend/utils/adt/datetime.c,v 1.16
2 2005/12/01 17:56:34 tgl
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -1013,7 +1013,10 @@ DecodeDateTime(char **field, int *ftype, int nf,
...
@@ -1013,7 +1013,10 @@ DecodeDateTime(char **field, int *ftype, int nf,
if
(
tzp
==
NULL
)
if
(
tzp
==
NULL
)
return
DTERR_BAD_FORMAT
;
return
DTERR_BAD_FORMAT
;
errno
=
0
;
val
=
strtol
(
field
[
i
],
&
cp
,
10
);
val
=
strtol
(
field
[
i
],
&
cp
,
10
);
if
(
errno
==
ERANGE
)
return
DTERR_FIELD_OVERFLOW
;
j2date
(
val
,
&
tm
->
tm_year
,
&
tm
->
tm_mon
,
&
tm
->
tm_mday
);
j2date
(
val
,
&
tm
->
tm_year
,
&
tm
->
tm_mon
,
&
tm
->
tm_mday
);
/* Get the time zone from the end of the string */
/* Get the time zone from the end of the string */
...
@@ -1158,7 +1161,10 @@ DecodeDateTime(char **field, int *ftype, int nf,
...
@@ -1158,7 +1161,10 @@ DecodeDateTime(char **field, int *ftype, int nf,
char
*
cp
;
char
*
cp
;
int
val
;
int
val
;
errno
=
0
;
val
=
strtol
(
field
[
i
],
&
cp
,
10
);
val
=
strtol
(
field
[
i
],
&
cp
,
10
);
if
(
errno
==
ERANGE
)
return
DTERR_FIELD_OVERFLOW
;
/*
/*
* only a few kinds are allowed to have an embedded
* only a few kinds are allowed to have an embedded
...
@@ -1915,7 +1921,10 @@ DecodeTimeOnly(char **field, int *ftype, int nf,
...
@@ -1915,7 +1921,10 @@ DecodeTimeOnly(char **field, int *ftype, int nf,
break
;
break
;
}
}
errno
=
0
;
val
=
strtol
(
field
[
i
],
&
cp
,
10
);
val
=
strtol
(
field
[
i
],
&
cp
,
10
);
if
(
errno
==
ERANGE
)
return
DTERR_FIELD_OVERFLOW
;
/*
/*
* only a few kinds are allowed to have an embedded
* only a few kinds are allowed to have an embedded
...
@@ -2456,11 +2465,17 @@ DecodeTime(char *str, int fmask, int *tmask, struct pg_tm * tm, fsec_t *fsec)
...
@@ -2456,11 +2465,17 @@ DecodeTime(char *str, int fmask, int *tmask, struct pg_tm * tm, fsec_t *fsec)
*
tmask
=
DTK_TIME_M
;
*
tmask
=
DTK_TIME_M
;
errno
=
0
;
tm
->
tm_hour
=
strtol
(
str
,
&
cp
,
10
);
tm
->
tm_hour
=
strtol
(
str
,
&
cp
,
10
);
if
(
errno
==
ERANGE
)
return
DTERR_FIELD_OVERFLOW
;
if
(
*
cp
!=
':'
)
if
(
*
cp
!=
':'
)
return
DTERR_BAD_FORMAT
;
return
DTERR_BAD_FORMAT
;
str
=
cp
+
1
;
str
=
cp
+
1
;
errno
=
0
;
tm
->
tm_min
=
strtol
(
str
,
&
cp
,
10
);
tm
->
tm_min
=
strtol
(
str
,
&
cp
,
10
);
if
(
errno
==
ERANGE
)
return
DTERR_FIELD_OVERFLOW
;
if
(
*
cp
==
'\0'
)
if
(
*
cp
==
'\0'
)
{
{
tm
->
tm_sec
=
0
;
tm
->
tm_sec
=
0
;
...
@@ -2471,7 +2486,10 @@ DecodeTime(char *str, int fmask, int *tmask, struct pg_tm * tm, fsec_t *fsec)
...
@@ -2471,7 +2486,10 @@ DecodeTime(char *str, int fmask, int *tmask, struct pg_tm * tm, fsec_t *fsec)
else
else
{
{
str
=
cp
+
1
;
str
=
cp
+
1
;
errno
=
0
;
tm
->
tm_sec
=
strtol
(
str
,
&
cp
,
10
);
tm
->
tm_sec
=
strtol
(
str
,
&
cp
,
10
);
if
(
errno
==
ERANGE
)
return
DTERR_FIELD_OVERFLOW
;
if
(
*
cp
==
'\0'
)
if
(
*
cp
==
'\0'
)
*
fsec
=
0
;
*
fsec
=
0
;
else
if
(
*
cp
==
'.'
)
else
if
(
*
cp
==
'.'
)
...
@@ -2522,7 +2540,10 @@ DecodeNumber(int flen, char *str, bool haveTextMonth, int fmask,
...
@@ -2522,7 +2540,10 @@ DecodeNumber(int flen, char *str, bool haveTextMonth, int fmask,
*
tmask
=
0
;
*
tmask
=
0
;
errno
=
0
;
val
=
strtol
(
str
,
&
cp
,
10
);
val
=
strtol
(
str
,
&
cp
,
10
);
if
(
errno
==
ERANGE
)
return
DTERR_FIELD_OVERFLOW
;
if
(
cp
==
str
)
if
(
cp
==
str
)
return
DTERR_BAD_FORMAT
;
return
DTERR_BAD_FORMAT
;
...
@@ -2809,11 +2830,19 @@ DecodeTimezone(char *str, int *tzp)
...
@@ -2809,11 +2830,19 @@ DecodeTimezone(char *str, int *tzp)
if
(
*
str
!=
'+'
&&
*
str
!=
'-'
)
if
(
*
str
!=
'+'
&&
*
str
!=
'-'
)
return
DTERR_BAD_FORMAT
;
return
DTERR_BAD_FORMAT
;
errno
=
0
;
hr
=
strtol
(
str
+
1
,
&
cp
,
10
);
hr
=
strtol
(
str
+
1
,
&
cp
,
10
);
if
(
errno
==
ERANGE
)
return
DTERR_TZDISP_OVERFLOW
;
/* explicit delimiter? */
/* explicit delimiter? */
if
(
*
cp
==
':'
)
if
(
*
cp
==
':'
)
{
errno
=
0
;
min
=
strtol
(
cp
+
1
,
&
cp
,
10
);
min
=
strtol
(
cp
+
1
,
&
cp
,
10
);
if
(
errno
==
ERANGE
)
return
DTERR_TZDISP_OVERFLOW
;
}
/* otherwise, might have run things together... */
/* otherwise, might have run things together... */
else
if
(
*
cp
==
'\0'
&&
strlen
(
str
)
>
3
)
else
if
(
*
cp
==
'\0'
&&
strlen
(
str
)
>
3
)
{
{
...
@@ -3056,7 +3085,10 @@ DecodeInterval(char **field, int *ftype, int nf, int *dtype, struct pg_tm * tm,
...
@@ -3056,7 +3085,10 @@ DecodeInterval(char **field, int *ftype, int nf, int *dtype, struct pg_tm * tm,
case
DTK_DATE
:
case
DTK_DATE
:
case
DTK_NUMBER
:
case
DTK_NUMBER
:
errno
=
0
;
val
=
strtol
(
field
[
i
],
&
cp
,
10
);
val
=
strtol
(
field
[
i
],
&
cp
,
10
);
if
(
errno
==
ERANGE
)
return
DTERR_FIELD_OVERFLOW
;
if
(
type
==
IGNORE_DTF
)
if
(
type
==
IGNORE_DTF
)
type
=
DTK_SECOND
;
type
=
DTK_SECOND
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment