summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/test')
-rw-r--r--src/test/isolation/isolation_main.c24
-rw-r--r--src/test/regress/pg_regress.c2
-rw-r--r--src/test/regress/pg_regress_main.c26
3 files changed, 38 insertions, 14 deletions
diff --git a/src/test/isolation/isolation_main.c b/src/test/isolation/isolation_main.c
index dc801b95e19..6ff54737efc 100644
--- a/src/test/isolation/isolation_main.c
+++ b/src/test/isolation/isolation_main.c
@@ -73,15 +73,27 @@ isolation_start_test(const char *testname,
add_stringlist_item(expectfiles, expectfile);
if (launcher)
+ {
offset += snprintf(psql_cmd + offset, sizeof(psql_cmd) - offset,
"%s ", launcher);
+ if (offset >= sizeof(psql_cmd))
+ {
+ fprintf(stderr, _("command too long\n"));
+ exit(2);
+ }
+ }
- snprintf(psql_cmd + offset, sizeof(psql_cmd) - offset,
- "\"%s\" \"dbname=%s\" < \"%s\" > \"%s\" 2>&1",
- isolation_exec,
- dblist->str,
- infile,
- outfile);
+ offset += snprintf(psql_cmd + offset, sizeof(psql_cmd) - offset,
+ "\"%s\" \"dbname=%s\" < \"%s\" > \"%s\" 2>&1",
+ isolation_exec,
+ dblist->str,
+ infile,
+ outfile);
+ if (offset >= sizeof(psql_cmd))
+ {
+ fprintf(stderr, _("command too long\n"));
+ exit(2);
+ }
pid = spawn_process(psql_cmd);
diff --git a/src/test/regress/pg_regress.c b/src/test/regress/pg_regress.c
index b1c73c6d23b..eb889f388ce 100644
--- a/src/test/regress/pg_regress.c
+++ b/src/test/regress/pg_regress.c
@@ -1097,7 +1097,7 @@ config_sspi_auth(const char *pgdata)
} while (0)
res = snprintf(fname, sizeof(fname), "%s/pg_hba.conf", pgdata);
- if (res < 0 || res >= sizeof(fname) - 1)
+ if (res < 0 || res >= sizeof(fname))
{
/*
* Truncating this name is a fatal error, because we must not fail to
diff --git a/src/test/regress/pg_regress_main.c b/src/test/regress/pg_regress_main.c
index 22197aa17d6..c1756151067 100644
--- a/src/test/regress/pg_regress_main.c
+++ b/src/test/regress/pg_regress_main.c
@@ -60,16 +60,28 @@ psql_start_test(const char *testname,
add_stringlist_item(expectfiles, expectfile);
if (launcher)
+ {
offset += snprintf(psql_cmd + offset, sizeof(psql_cmd) - offset,
"%s ", launcher);
+ if (offset >= sizeof(psql_cmd))
+ {
+ fprintf(stderr, _("command too long\n"));
+ exit(2);
+ }
+ }
- snprintf(psql_cmd + offset, sizeof(psql_cmd) - offset,
- "\"%s%spsql\" -X -a -q -d \"%s\" < \"%s\" > \"%s\" 2>&1",
- psqldir ? psqldir : "",
- psqldir ? "/" : "",
- dblist->str,
- infile,
- outfile);
+ offset += snprintf(psql_cmd + offset, sizeof(psql_cmd) - offset,
+ "\"%s%spsql\" -X -a -q -d \"%s\" < \"%s\" > \"%s\" 2>&1",
+ psqldir ? psqldir : "",
+ psqldir ? "/" : "",
+ dblist->str,
+ infile,
+ outfile);
+ if (offset >= sizeof(psql_cmd))
+ {
+ fprintf(stderr, _("command too long\n"));
+ exit(2);
+ }
pid = spawn_process(psql_cmd);