Skip to content

Commit 8fd2e26

Browse files
committed
MakeRetrieveViewRuleName was scribbling on memory that didn't belong
to it. Bad dog.
1 parent a8aa2f9 commit 8fd2e26

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

src/backend/commands/view.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Id: view.c,v 1.51 2000/12/21 17:36:15 tgl Exp $
9+
* $Id: view.c,v 1.52 2001/01/03 18:43:09 tgl Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -110,19 +110,20 @@ char *
110110
MakeRetrieveViewRuleName(char *viewName)
111111
{
112112
char *buf;
113-
#ifdef MULTIBYTE
114-
int len;
115-
#endif
116-
117-
buf = palloc(strlen(viewName) + 5);
118-
snprintf(buf, strlen(viewName) + 5, "_RET%s", viewName);
113+
int buflen,
114+
maxlen;
119115

116+
buflen = strlen(viewName) + 5;
117+
buf = palloc(buflen);
118+
snprintf(buf, buflen, "_RET%s", viewName);
119+
/* clip to less than NAMEDATALEN bytes, if necessary */
120120
#ifdef MULTIBYTE
121-
len = pg_mbcliplen(buf,strlen(buf),NAMEDATALEN-1);
122-
buf[len] = '\0';
121+
maxlen = pg_mbcliplen(buf, strlen(buf), NAMEDATALEN-1);
123122
#else
124-
buf[NAMEDATALEN-1] = '\0';
123+
maxlen = NAMEDATALEN-1;
125124
#endif
125+
if (maxlen < buflen)
126+
buf[maxlen] = '\0';
126127

127128
return buf;
128129
}

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