Fix two memcpy() bugs in the new injection point code
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Mon, 22 Jan 2024 18:55:45 +0000 (20:55 +0200)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Mon, 22 Jan 2024 18:55:45 +0000 (20:55 +0200)
commit0eb23285a2579591c09a591e5a52829f65665341
tree0437e954488bd5c6547cf51f42376d3e106163bc
parent49f7c6c44a5f6a7f7b39d140e490c9c627511893
Fix two memcpy() bugs in the new injection point code

1. The memcpy()s in InjectionPointAttach() would copy garbage from
beyond the end of input string to the buffer in shared memory. You
won't usually notice, but if there is not enough valid mapped memory
beyond the end of the string, the read of unmapped memory will
segfault. This was flagged by the Cirrus CI build with address
sanitizer enabled.

2. The memcpy() in injection_point_cache_add() failed to copy the NULL
terminator.

Discussion: https://www.postgresql.org/message-id/0615a424-b726-4157-afa7-4245629f9512%40iki.fi
src/backend/utils/misc/injection_point.c