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

Commit2271d00

Browse files
committed
Fix "path" infrastructure bug affecting jsonb_set()
jsonb_set() and other clients of the setPathArray() utility functioncould get spurious results when an array integer subscript is providedthat is not within the range of int.To fix, ensure that the value returned by strtol() within setPathArray()is within the range of int; when it isn't, assume an invalid input inline with existing, similar cases. The path-orientated operators thatappeared in PostgreSQL 9.3 and 9.4 do not call setPathArray(), andalready independently take this precaution, so no change there.Peter Geoghegan
1 parentae58f14 commit2271d00

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3814,11 +3814,14 @@ setPathArray(JsonbIterator **it, Datum *path_elems, bool *path_nulls,
38143814
if (level<path_len&& !path_nulls[level])
38153815
{
38163816
char*c=VARDATA_ANY(path_elems[level]);
3817+
longlindex;
38173818

38183819
errno=0;
3819-
idx= (int)strtol(c,&badp,10);
3820-
if (errno!=0||badp==c)
3820+
lindex=strtol(c,&badp,10);
3821+
if (errno!=0||badp==c||lindex>INT_MAX||lindex<INT_MIN)
38213822
idx=nelems;
3823+
else
3824+
idx=lindex;
38223825
}
38233826
else
38243827
idx=nelems;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp