Avoid incomplete copy string (src/backend/access/transam/xlog.c)
Ranier Vilela <ranier.vf@gmail.com>
From: Ranier Vilela <ranier.vf@gmail.com>
To: Pg Hackers <pgsql-hackers@postgresql.org>
Date: 2024-06-23T23:51:26Z
Lists: pgsql-hackers
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Use safe string copy routine
- e930c872b65c 18.0 landed
Attachments
- avoid-incomplete-copy-string-do_pg_backup_start.patch (application/octet-stream) patch
Hi. In src/include/access/xlogbackup.h, the field *name* has one byte extra to store null-termination. But, in the function *do_pg_backup_start*, I think that is a mistake in the line (8736): memcpy(state->name, backupidstr, strlen(backupidstr)); memcpy with strlen does not copy the whole string. strlen returns the exact length of the string, without the null-termination. So, I think this can result in errors, like in the function *build_backup_content* (src/backend/access/transam/xlogbackup.c) Where *appendStringInfo* expects a string with null-termination. appendStringInfo(result, "LABEL: %s\n", state->name); To fix, copy strlen size plus one byte, to include the null-termination. Trivial patch attached. best regards, Ranier Vilela