From: Michael Paquier Date: Mon, 13 Apr 2026 00:06:17 +0000 (+0900) Subject: test_saslprep: Fix issue with copy of input bytea X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5d35531af1840fdd8debfc1ff657643ddba029ab;p=thirdparty%2Fpostgresql.git test_saslprep: Fix issue with copy of input bytea The data given in input of the function may not be null-terminated, causing strlcpy() to complain with an invalid read. Issue spotted using valgrind. Reported-by: Alexander Lakhin Discussion: https://postgr.es/m/09df9d75-13e7-45fe-89af-33fe118e797b@gmail.com --- diff --git a/src/test/modules/test_saslprep/test_saslprep.c b/src/test/modules/test_saslprep/test_saslprep.c index 70ff7069bf7..121212d4fa2 100644 --- a/src/test/modules/test_saslprep/test_saslprep.c +++ b/src/test/modules/test_saslprep/test_saslprep.c @@ -84,7 +84,8 @@ test_saslprep(PG_FUNCTION_ARGS) * Copy the input given, to make SASLprep() act on a sanitized string. */ input_data = palloc0(src_len + 1); - strlcpy(input_data, src, src_len + 1); + memcpy(input_data, src, src_len); + input_data[src_len] = '\0'; rc = pg_saslprep(input_data, &result); status = saslprep_status_to_text(rc);