Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8090616

Browse files
committed
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 parserwould always have truncated the identifier to NAMEDATALEN-1 already,but let's be safe. Per report from Klocwork.
1 parent2ee3a72 commit8090616

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

‎src/backend/commands/prepare.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* Copyright (c) 2002-2004, PostgreSQL Global Development Group
1111
*
1212
* IDENTIFICATION
13-
* $PostgreSQL: pgsql/src/backend/commands/prepare.c,v 1.33 2004/10/25 00:46:40 neilc Exp $
13+
* $PostgreSQL: pgsql/src/backend/commands/prepare.c,v 1.34 2004/12/03 21:26:31 tgl Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -296,8 +296,7 @@ StorePreparedStatement(const char *stmt_name,
296296

297297
/* Check for pre-existing entry of same name */
298298
/* See notes in FetchPreparedStatement */
299-
MemSet(key,0,sizeof(key));
300-
strncpy(key,stmt_name,sizeof(key));
299+
StrNCpy(key,stmt_name,sizeof(key));
301300

302301
hash_search(prepared_queries,key,HASH_FIND,&found);
303302

@@ -370,8 +369,7 @@ FetchPreparedStatement(const char *stmt_name, bool throwError)
370369
* the hash package is picky enough that it needs to be
371370
* NULL-padded out to the appropriate length to work correctly.
372371
*/
373-
MemSet(key,0,sizeof(key));
374-
strncpy(key,stmt_name,sizeof(key));
372+
StrNCpy(key,stmt_name,sizeof(key));
375373

376374
entry= (PreparedStatement*)hash_search(prepared_queries,
377375
key,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp