mirror of
https://github.com/postgres/postgres.git
synced 2025-08-02 09:26:47 +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;
|
||||
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';
|
||||
|
Reference in New Issue
Block a user