Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf1f6737

Browse files
committed
Fix incorrect logic in JSON number lexer
Detectable by gcc -Wlogical-op.Add two regression test cases that would previously allow incorrectvalues to pass.
1 parentfe2534e commitf1f6737

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

‎src/backend/utils/adt/json.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ json_lex_number(JsonLexContext *lex, char *s)
541541
if (*s=='.')
542542
{
543543
++s;
544-
if (*s<'0'&&*s>'9')
544+
if (*s<'0'||*s>'9')
545545
error= true;
546546
else
547547
{
@@ -558,7 +558,7 @@ json_lex_number(JsonLexContext *lex, char *s)
558558
++s;
559559
if (*s=='+'||*s=='-')
560560
++s;
561-
if (*s<'0'&&*s>'9')
561+
if (*s<'0'||*s>'9')
562562
error= true;
563563
else
564564
{

‎src/test/regress/expected/json.out

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,16 @@ ERROR: invalid input syntax for type json
113113
LINE 1: SELECT '1f2'::json;
114114
^
115115
DETAIL: line 1: Token "1f2" is invalid.
116+
SELECT '0.x1'::json;-- ERROR
117+
ERROR: invalid input syntax for type json
118+
LINE 1: SELECT '0.x1'::json;
119+
^
120+
DETAIL: line 1: Token "0.x1" is invalid.
121+
SELECT '1.3ex100'::json;-- ERROR
122+
ERROR: invalid input syntax for type json
123+
LINE 1: SELECT '1.3ex100'::json;
124+
^
125+
DETAIL: line 1: Token "1.3ex100" is invalid.
116126
-- Arrays.
117127
SELECT '[]'::json;-- OK
118128
json

‎src/test/regress/sql/json.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ SELECT '9223372036854775808'::json;-- OK, even though it's too large for int8
2222
SELECT'1e100'::json;-- OK
2323
SELECT'1.3e100'::json;-- OK
2424
SELECT'1f2'::json;-- ERROR
25+
SELECT'0.x1'::json;-- ERROR
26+
SELECT'1.3ex100'::json;-- ERROR
2527

2628
-- Arrays.
2729
SELECT'[]'::json;-- OK

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp