mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-01-30 19:00:29 +08:00
Use StrNCpy not strncpy to fill hash key, to ensure the resulting key
is null-terminated. I think this is not a real bug because the parser would always have truncated the identifier to NAMEDATALEN-1 already, but let's be safe. Per report from Klocwork.
This commit is contained in:
parent
2ee3a720a4
commit
8090616847
@ -10,7 +10,7 @@
|
|||||||
* Copyright (c) 2002-2004, PostgreSQL Global Development Group
|
* Copyright (c) 2002-2004, PostgreSQL Global Development Group
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/commands/prepare.c,v 1.33 2004/10/25 00:46:40 neilc Exp $
|
* $PostgreSQL: pgsql/src/backend/commands/prepare.c,v 1.34 2004/12/03 21:26:31 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -296,8 +296,7 @@ StorePreparedStatement(const char *stmt_name,
|
|||||||
|
|
||||||
/* Check for pre-existing entry of same name */
|
/* Check for pre-existing entry of same name */
|
||||||
/* See notes in FetchPreparedStatement */
|
/* See notes in FetchPreparedStatement */
|
||||||
MemSet(key, 0, sizeof(key));
|
StrNCpy(key, stmt_name, sizeof(key));
|
||||||
strncpy(key, stmt_name, sizeof(key));
|
|
||||||
|
|
||||||
hash_search(prepared_queries, key, HASH_FIND, &found);
|
hash_search(prepared_queries, key, HASH_FIND, &found);
|
||||||
|
|
||||||
@ -370,8 +369,7 @@ FetchPreparedStatement(const char *stmt_name, bool throwError)
|
|||||||
* the hash package is picky enough that it needs to be
|
* the hash package is picky enough that it needs to be
|
||||||
* NULL-padded out to the appropriate length to work correctly.
|
* NULL-padded out to the appropriate length to work correctly.
|
||||||
*/
|
*/
|
||||||
MemSet(key, 0, sizeof(key));
|
StrNCpy(key, stmt_name, sizeof(key));
|
||||||
strncpy(key, stmt_name, sizeof(key));
|
|
||||||
|
|
||||||
entry = (PreparedStatement *) hash_search(prepared_queries,
|
entry = (PreparedStatement *) hash_search(prepared_queries,
|
||||||
key,
|
key,
|
||||||
|
Loading…
Reference in New Issue
Block a user