mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
Get rid of unsafe sprintf and snprintf usages. Per compiler warnings.
This commit is contained in:
@ -62,10 +62,10 @@ get_control_data(migratorContext *ctx, ClusterInfo *cluster, bool live_check)
|
|||||||
#else
|
#else
|
||||||
SetEnvironmentVariableA("LANG", "C");
|
SetEnvironmentVariableA("LANG", "C");
|
||||||
#endif
|
#endif
|
||||||
sprintf(cmd, SYSTEMQUOTE "\"%s/%s \"%s\"" SYSTEMQUOTE,
|
snprintf(cmd, sizeof(cmd), SYSTEMQUOTE "\"%s/%s \"%s\"" SYSTEMQUOTE,
|
||||||
cluster->bindir,
|
cluster->bindir,
|
||||||
live_check ? "pg_controldata\"" : "pg_resetxlog\" -n",
|
live_check ? "pg_controldata\"" : "pg_resetxlog\" -n",
|
||||||
cluster->pgdata);
|
cluster->pgdata);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
fflush(stderr);
|
fflush(stderr);
|
||||||
|
|
||||||
|
@ -362,10 +362,10 @@ get_rel_infos(migratorContext *ctx, const DbInfo *dbinfo,
|
|||||||
curr->reloid = atol(PQgetvalue(res, relnum, i_oid));
|
curr->reloid = atol(PQgetvalue(res, relnum, i_oid));
|
||||||
|
|
||||||
nspname = PQgetvalue(res, relnum, i_nspname);
|
nspname = PQgetvalue(res, relnum, i_nspname);
|
||||||
snprintf(curr->nspname, sizeof(curr->nspname), nspname);
|
strlcpy(curr->nspname, nspname, sizeof(curr->nspname));
|
||||||
|
|
||||||
relname = PQgetvalue(res, relnum, i_relname);
|
relname = PQgetvalue(res, relnum, i_relname);
|
||||||
snprintf(curr->relname, sizeof(curr->relname), relname);
|
strlcpy(curr->relname, relname, sizeof(curr->relname));
|
||||||
|
|
||||||
curr->relfilenode = atol(PQgetvalue(res, relnum, i_relfilenode));
|
curr->relfilenode = atol(PQgetvalue(res, relnum, i_relfilenode));
|
||||||
curr->toastrelid = atol(PQgetvalue(res, relnum, i_reltoastrelid));
|
curr->toastrelid = atol(PQgetvalue(res, relnum, i_reltoastrelid));
|
||||||
@ -374,7 +374,7 @@ get_rel_infos(migratorContext *ctx, const DbInfo *dbinfo,
|
|||||||
/* if no table tablespace, use the database tablespace */
|
/* if no table tablespace, use the database tablespace */
|
||||||
if (strlen(tblspace) == 0)
|
if (strlen(tblspace) == 0)
|
||||||
tblspace = dbinfo->db_tblspace;
|
tblspace = dbinfo->db_tblspace;
|
||||||
snprintf(curr->tablespace, sizeof(curr->tablespace), "%s", tblspace);
|
strlcpy(curr->tablespace, tblspace, sizeof(curr->tablespace));
|
||||||
}
|
}
|
||||||
PQclear(res);
|
PQclear(res);
|
||||||
|
|
||||||
|
@ -178,10 +178,11 @@ start_postmaster(migratorContext *ctx, Cluster whichCluster, bool quiet)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* use -l for Win32 */
|
/* use -l for Win32 */
|
||||||
sprintf(cmd, SYSTEMQUOTE "\"%s/pg_ctl\" -l \"%s\" -D \"%s\" "
|
snprintf(cmd, sizeof(cmd),
|
||||||
"-o \"-p %d -c autovacuum=off -c autovacuum_freeze_max_age=2000000000\" "
|
SYSTEMQUOTE "\"%s/pg_ctl\" -l \"%s\" -D \"%s\" "
|
||||||
"start >> \"%s\" 2>&1" SYSTEMQUOTE,
|
"-o \"-p %d -c autovacuum=off -c autovacuum_freeze_max_age=2000000000\" "
|
||||||
bindir, ctx->logfile, datadir, port, ctx->logfile);
|
"start >> \"%s\" 2>&1" SYSTEMQUOTE,
|
||||||
|
bindir, ctx->logfile, datadir, port, ctx->logfile);
|
||||||
exec_prog(ctx, true, "%s", cmd);
|
exec_prog(ctx, true, "%s", cmd);
|
||||||
|
|
||||||
/* wait for the server to start properly */
|
/* wait for the server to start properly */
|
||||||
|
Reference in New Issue
Block a user