summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Dunstan2025-04-06 13:21:09 +0000
committerAndrew Dunstan2025-04-06 13:21:09 +0000
commit5e1915439085014140314979c4dd5e23bd677cac (patch)
tree5c9d68506ccd70a1628498a65fcb6bd891b4628c
parent6d5417e634b3841dcc44bdb43f5586bcde33ddb4 (diff)
Avoid unnecessary copying of a string in pg_restore.c
Coverity complained about a possible overrun in the copy, but there is no actual need to copy the string at all.
-rw-r--r--src/bin/pg_dump/pg_restore.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/bin/pg_dump/pg_restore.c b/src/bin/pg_dump/pg_restore.c
index c42e34b8a40..b3dbde0d044 100644
--- a/src/bin/pg_dump/pg_restore.c
+++ b/src/bin/pg_dump/pg_restore.c
@@ -1052,14 +1052,14 @@ get_dbname_oid_list_from_mfile(const char *dumpdirpath, SimpleOidStringList *dbn
{
Oid db_oid = InvalidOid;
char db_oid_str[MAXPGPATH + 1] = "";
- char dbname[MAXPGPATH + 1] = "";
+ char *dbname;
/* Extract dboid. */
sscanf(line, "%u", &db_oid);
sscanf(line, "%20s", db_oid_str);
- /* Now copy dbname. */
- strcpy(dbname, line + strlen(db_oid_str) + 1);
+ /* dbname is the rest of the line */
+ dbname = line + strlen(db_oid_str) + 1;
/* Remove \n from dbname. */
dbname[strlen(dbname) - 1] = '\0';