Skip to content

Commit 72ed6ff

Browse files
committed
In PQfn(), defend against too many args, and avoid dependency
on FUNC_MAX_ARGS by using an appropriate fmgr() call.
1 parent ef899c7 commit 72ed6ff

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/backend/libpq/be-pqexec.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/libpq/Attic/be-pqexec.c,v 1.28 2000/01/11 03:33:12 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/libpq/Attic/be-pqexec.c,v 1.29 2000/01/12 05:27:20 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -58,12 +58,16 @@ PQfn(int fnid,
5858
{
5959
char *retval; /* XXX - should be datum, maybe ? */
6060
char *arg[FUNC_MAX_ARGS];
61+
bool isNull;
6162
int i;
6263

6364
/* ----------------
6465
* fill args[] array
6566
* ----------------
6667
*/
68+
if (nargs > FUNC_MAX_ARGS)
69+
elog(ERROR, "functions cannot have more than %d arguments",
70+
FUNC_MAX_ARGS);
6771
for (i = 0; i < nargs; i++)
6872
{
6973
if (args[i].len == VAR_LENGTH_ARG)
@@ -78,18 +82,14 @@ PQfn(int fnid,
7882
* call the postgres function manager
7983
* ----------------
8084
*/
81-
retval = (char *)
82-
fmgr(fnid, arg[0], arg[1], arg[2], arg[3],
83-
arg[4], arg[5], arg[6], arg[7],
84-
arg[8], arg[9], arg[10], arg[11],
85-
arg[12], arg[13], arg[14], arg[15]);
85+
retval = fmgr_array_args(fnid, nargs, arg, &isNull);
8686

8787
/* ----------------
8888
* put the result in the buffer the user specified and
8989
* return the proper code.
9090
* ----------------
9191
*/
92-
if (retval == (char *) NULL)/* void retval */
92+
if (isNull) /* void retval */
9393
return "0";
9494

9595
if (result_is_int)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy