diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2024-10-16 12:24:57 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2024-10-16 12:25:00 -0400 |
commit | 9b4bf5169064044ff082c61bf0783c4a65c08734 (patch) | |
tree | 292ff21a72707003e614596856315f52bd0a2d41 /src/interfaces/ecpg/preproc/variable.c | |
parent | 79fa7b3b1a449680d9e51624834fbb4b32208659 (diff) | |
download | postgresql-9b4bf5169064044ff082c61bf0783c4a65c08734.tar.gz postgresql-9b4bf5169064044ff082c61bf0783c4a65c08734.zip |
ecpg: fix some minor mishandling of bad input in preprocessor.
Avoid null-pointer crash when considering a cursor declaration
that's outside any C function (a case which is useless anyway).
Ensure a cursor for a prepared statement is marked as initially
not open. At worst, if we chanced to get not-already-zeroed memory
from malloc(), this oversight would result in failing to issue a
"cursor "foo" has been declared but not opened" warning that would
have been appropriate.
Avoid running off the end of the buffer when there are mismatched
square brackets following a variable name. This could lead to
SIGSEGV after reaching the end of memory.
Given the lack of field complaints, none of these seem to be worth
back-patching, but let's clean them up in HEAD.
Per valgrind testing by Alexander Lakhin.
Discussion: https://postgr.es/m/5f5bcecd-d7ec-b8c0-6c92-d1a7c6e0f639@gmail.com
Diffstat (limited to 'src/interfaces/ecpg/preproc/variable.c')
-rw-r--r-- | src/interfaces/ecpg/preproc/variable.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/interfaces/ecpg/preproc/variable.c b/src/interfaces/ecpg/preproc/variable.c index 6b87d5ff3d9..a4294b8f0ff 100644 --- a/src/interfaces/ecpg/preproc/variable.c +++ b/src/interfaces/ecpg/preproc/variable.c @@ -216,6 +216,9 @@ find_variable(const char *name) case ']': count--; break; + case '\0': + mmfatal(PARSE_ERROR, "unmatched brace in variable \"%s\"", name); + break; default: break; } |