diff -ruN postgresql-7.4.5-old/src/pl/plpgsql/src/gram.y postgresql-7.4.5/src/pl/plpgsql/src/gram.y --- postgresql-7.4.5-old/src/pl/plpgsql/src/gram.y 2003-10-30 18:18:55.000000000 +0100 +++ postgresql-7.4.5/src/pl/plpgsql/src/gram.y 2005-02-10 13:24:10.871958168 +0100 @@ -512,6 +512,10 @@ { int i = $1->nfields++; + /* Guard against overflowing the array on malicious input */ + if (i >= 1024) + yyerror("too many parameters specified for refcursor"); + $1->fieldnames[i] = $3->refname; $1->varnos[i] = $3->varno;