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

Commit0eb2328

Browse files
committed
Fix two memcpy() bugs in the new injection point code
1. The memcpy()s in InjectionPointAttach() would copy garbage frombeyond the end of input string to the buffer in shared memory. Youwon't usually notice, but if there is not enough valid mapped memorybeyond the end of the string, the read of unmapped memory willsegfault. This was flagged by the Cirrus CI build with addresssanitizer enabled.2. The memcpy() in injection_point_cache_add() failed to copy the NULLterminator.Discussion:https://www.postgresql.org/message-id/0615a424-b726-4157-afa7-4245629f9512%40iki.fi
1 parent49f7c6c commit0eb2328

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

‎src/backend/utils/misc/injection_point.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ injection_point_cache_add(const char *name,
9797
hash_search(InjectionPointCache,name,HASH_ENTER,&found);
9898

9999
Assert(!found);
100-
memcpy(entry->name,name,strlen(name));
100+
strlcpy(entry->name,name,sizeof(entry->name));
101101
entry->callback=callback;
102102
}
103103

@@ -217,11 +217,11 @@ InjectionPointAttach(const char *name,
217217
}
218218

219219
/* Save the entry */
220-
memcpy(entry_by_name->name,name,sizeof(entry_by_name->name));
220+
strlcpy(entry_by_name->name,name,sizeof(entry_by_name->name));
221221
entry_by_name->name[INJ_NAME_MAXLEN-1]='\0';
222-
memcpy(entry_by_name->library,library,sizeof(entry_by_name->library));
222+
strlcpy(entry_by_name->library,library,sizeof(entry_by_name->library));
223223
entry_by_name->library[INJ_LIB_MAXLEN-1]='\0';
224-
memcpy(entry_by_name->function,function,sizeof(entry_by_name->function));
224+
strlcpy(entry_by_name->function,function,sizeof(entry_by_name->function));
225225
entry_by_name->function[INJ_FUNC_MAXLEN-1]='\0';
226226

227227
LWLockRelease(InjectionPointLock);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp