mirror of
https://github.com/postgres/postgres.git
synced 2025-07-30 11:03:19 +03:00
Protect against overflow of ltree.numlevel and lquery.numlevel.
These uint16 fields could be overflowed by excessively long input, producing strange results. Complain for invalid input. Likewise check for out-of-range values of the repeat counts in lquery. (We don't try too hard on that one, notably not bothering to detect if atoi's result has overflowed.) Also detect length overflow in ltree_concat. In passing, be more consistent about whether "syntax error" messages include the type name. Also, clarify the documentation about what the size limit is. This has been broken for a long time, so back-patch to all supported branches. Nikita Glukhov, reviewed by Benjie Gillam and Tomas Vondra Discussion: https://postgr.es/m/CAP_rww=waX2Oo6q+MbMSiZ9ktdj6eaJj0cQzNu=Ry2cCDij5fw@mail.gmail.com
This commit is contained in:
@ -25,6 +25,7 @@ typedef struct
|
||||
|
||||
#define LTREE_HDRSIZE MAXALIGN( offsetof(ltree, data) )
|
||||
#define LTREE_FIRST(x) ( (ltree_level*)( ((char*)(x))+LTREE_HDRSIZE ) )
|
||||
#define LTREE_MAX_LEVELS PG_UINT16_MAX /* ltree.numlevel is uint16 */
|
||||
|
||||
|
||||
/* lquery */
|
||||
@ -77,6 +78,7 @@ typedef struct
|
||||
|
||||
#define LQUERY_HDRSIZE MAXALIGN( offsetof(lquery, data) )
|
||||
#define LQUERY_FIRST(x) ( (lquery_level*)( ((char*)(x))+LQUERY_HDRSIZE ) )
|
||||
#define LQUERY_MAX_LEVELS PG_UINT16_MAX /* lquery.numlevel is uint16 */
|
||||
|
||||
#define LQUERY_HASNOT 0x01
|
||||
|
||||
|
Reference in New Issue
Block a user