From 3fafac3f628ccfb23f3652b1c30b338cb8286893 Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Tue, 4 Jul 2006 13:22:15 +0000 Subject: Remove libpq's PQescapeIdentifier(), not safe from injection attacks. --- doc/src/sgml/libpq.sgml | 64 +------------------------------------------------ 1 file changed, 1 insertion(+), 63 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/libpq.sgml b/doc/src/sgml/libpq.sgml index 7dec1214c83..4d8b29de726 100644 --- a/doc/src/sgml/libpq.sgml +++ b/doc/src/sgml/libpq.sgml @@ -1,4 +1,4 @@ - + <application>libpq</application> - C Library @@ -2279,68 +2279,6 @@ in favor of PQescapeStringConn. - - Escaping Identifier for Inclusion in SQL Commands - - PQescapeIdentifier - escaping strings - - -PQescapeIdentifier escapes a string for use -as an identifier name within an SQL command. For example; table names, -column names, view names and user names are all identifiers. -Double quotes (") must be escaped to prevent them from being interpreted -specially by the SQL parser. PQescapeIdentifier performs this -operation. - - - - -It is especially important to do proper escaping when handling strings that -were received from an untrustworthy source. Otherwise there is a security -risk: you are vulnerable to SQL injection attacks wherein unwanted -SQL commands are fed to your database. - - - - -Note that it is still necessary to do escaping of identifiers when -using functions that support parameterized queries such as PQexecParams or -its sibling routines. Only literal values are automatically escaped -using these functions, not identifiers. - - -size_t PQescapeIdentifier (char *to, const char *from, size_t length); - - - - -The parameter from points to the first character of the -string that is to be escaped, and the length parameter -gives the number of characters in this string. A terminating zero byte -is not required, and should not be counted in length. (If -a terminating zero byte is found before length bytes are -processed, PQescapeIdentifier stops at the zero; the -behavior is thus rather like strncpy.) to -shall point to a buffer that is able to hold at least one more character -than twice the value of length, otherwise the behavior is -undefined. A call to PQescapeIdentifier writes an escaped -version of the from string to the to buffer, -replacing special characters so that they cannot cause any harm, and -adding a terminating zero byte. The double quotes that may surround -PostgreSQL identifiers are not included in the result -string; they should be provided in the SQL command that the result is -inserted into. - - -PQescapeIdentifier returns the number of characters written -to to, not including the terminating zero byte. - - -Behavior is undefined if the to and from -strings overlap. - - Escaping Binary Strings for Inclusion in SQL Commands -- cgit v1.2.3