Skip to content

Commit b13da41

Browse files
committed
Fix unsafe loop test, and declare as_ident as bool rather than int.
1 parent d666796 commit b13da41

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/interfaces/libpq/fe-exec.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-exec.c,v 1.207 2010/01/21 14:58:53 rhaas Exp $
11+
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-exec.c,v 1.208 2010/01/21 18:43:25 rhaas Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -3066,7 +3066,7 @@ PQescapeString(char *to, const char *from, size_t length)
30663066
* of memory condition, we return NULL, storing an error message into conn.
30673067
*/
30683068
static char *
3069-
PQescapeInternal(PGconn *conn, const char *str, size_t len, int as_ident)
3069+
PQescapeInternal(PGconn *conn, const char *str, size_t len, bool as_ident)
30703070
{
30713071
const char *s;
30723072
char *result;
@@ -3082,7 +3082,7 @@ PQescapeInternal(PGconn *conn, const char *str, size_t len, int as_ident)
30823082
return NULL;
30833083

30843084
/* Scan the string for characters that must be escaped. */
3085-
for (s = str; *s != '\0' && (s - str) < len; ++s)
3085+
for (s = str; (s - str) < len && *s != '\0'; ++s)
30863086
{
30873087
if (*s == quote_char)
30883088
++num_quotes;
@@ -3188,13 +3188,13 @@ PQescapeInternal(PGconn *conn, const char *str, size_t len, int as_ident)
31883188
char *
31893189
PQescapeLiteral(PGconn *conn, const char *str, size_t len)
31903190
{
3191-
return PQescapeInternal(conn, str, len, 0);
3191+
return PQescapeInternal(conn, str, len, false);
31923192
}
31933193

31943194
char *
31953195
PQescapeIdentifier(PGconn *conn, const char *str, size_t len)
31963196
{
3197-
return PQescapeInternal(conn, str, len, 1);
3197+
return PQescapeInternal(conn, str, len, true);
31983198
}
31993199

32003200
/* HEX encoding support for bytea */

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