Skip to content

Commit d0c0c89

Browse files
committed
Fix unsafe extraction of the OID part of a relation filename.
Commit 8694cc9 did this randomly differently from other callers of parse_filename_for_nontemp_relation(). Perhaps unsurprisingly, the randomly different way is wrong; it fails to ensure the extracted string is null-terminated. Per buildfarm member skink. Discussion: https://postgr.es/m/14453.1522001792@sss.pgh.pa.us
1 parent bf4a867 commit d0c0c89

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/backend/replication/basebackup.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -1056,7 +1056,8 @@ sendDir(const char *path, int basepathlen, bool sizeonly, List *tablespaces,
10561056
* If any other type of fork, check if there is an init fork
10571057
* with the same OID. If so, the file can be excluded.
10581058
*/
1059-
strncpy(relOid, de->d_name, relOidChars);
1059+
memcpy(relOid, de->d_name, relOidChars);
1060+
relOid[relOidChars] = '\0';
10601061
snprintf(initForkFile, sizeof(initForkFile), "%s/%s_init",
10611062
path, relOid);
10621063

0 commit comments

Comments
 (0)