Only adjust negative indexes in json_get up to the length of the path.

Andrew Dunstan <andrew@dunslane.net>

Commit: 6d10f4e9d7f0051afb60c42409f2fe61cf4da348
Author: Andrew Dunstan <andrew@dunslane.net>
Date: 2015-07-28T21:54:13Z
Releases: 9.6.0
Only adjust negative indexes in json_get up to the length of the path.

The previous code resulted in memory access beyond the path bounds. The
cure is to move it into a code branch that checks the value of lex_level
is within the correct bounds.

Bug reported and diagnosed by Piotr Stefaniak.

Files

PathChange+/−
src/backend/utils/adt/jsonfuncs.c modified +13 −13