mirror of
https://github.com/postgres/postgres.git
synced 2025-08-05 07:41:25 +03:00
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.
This commit is contained in:
@@ -1052,14 +1052,14 @@ get_dbname_oid_list_from_mfile(const char *dumpdirpath, SimpleOidStringList *dbn
|
|||||||
{
|
{
|
||||||
Oid db_oid = InvalidOid;
|
Oid db_oid = InvalidOid;
|
||||||
char db_oid_str[MAXPGPATH + 1] = "";
|
char db_oid_str[MAXPGPATH + 1] = "";
|
||||||
char dbname[MAXPGPATH + 1] = "";
|
char *dbname;
|
||||||
|
|
||||||
/* Extract dboid. */
|
/* Extract dboid. */
|
||||||
sscanf(line, "%u", &db_oid);
|
sscanf(line, "%u", &db_oid);
|
||||||
sscanf(line, "%20s", db_oid_str);
|
sscanf(line, "%20s", db_oid_str);
|
||||||
|
|
||||||
/* Now copy dbname. */
|
/* dbname is the rest of the line */
|
||||||
strcpy(dbname, line + strlen(db_oid_str) + 1);
|
dbname = line + strlen(db_oid_str) + 1;
|
||||||
|
|
||||||
/* Remove \n from dbname. */
|
/* Remove \n from dbname. */
|
||||||
dbname[strlen(dbname) - 1] = '\0';
|
dbname[strlen(dbname) - 1] = '\0';
|
||||||
|
Reference in New Issue
Block a user