diff options
| author | Stephen Frost | 2014-03-02 03:14:14 +0000 |
|---|---|---|
| committer | Stephen Frost | 2014-03-02 03:14:14 +0000 |
| commit | b1aebbb6a86e96d7b8f3035ac730dfc24652496c (patch) | |
| tree | 838f5464cf1a76766cf182ac4e812f3056297812 /src/test/regress | |
| parent | 9662143f0c35d64d7042fbeaf879df8f0b54be32 (diff) | |
Various Coverity-spotted fixes
A number of issues were identified by the Coverity scanner and are
addressed in this patch. None of these appear to be security issues
and many are mostly cosmetic changes.
Short comments for each of the changes follows.
Correct the semi-colon placement in be-secure.c regarding SSL retries.
Remove a useless comparison-to-NULL in proc.c (value is dereferenced
prior to this check and therefore can't be NULL).
Add checking of chmod() return values to initdb.
Fix a couple minor memory leaks in initdb.
Fix memory leak in pg_ctl- involves free'ing the config file contents.
Use an int to capture fgetc() return instead of an enum in pg_dump.
Fix minor memory leaks in pg_dump.
(note minor change to convertOperatorReference()'s API)
Check fclose()/remove() return codes in psql.
Check fstat(), find_my_exec() return codes in psql.
Various ECPG memory leak fixes.
Check find_my_exec() return in ECPG.
Explicitly ignore pqFlush return in libpq error-path.
Change PQfnumber() to avoid doing an strdup() when no changes required.
Remove a few useless check-against-NULL's (value deref'd beforehand).
Check rmtree(), malloc() results in pg_regress.
Also check get_alternative_expectfile() return in pg_regress.
Diffstat (limited to 'src/test/regress')
| -rw-r--r-- | src/test/regress/pg_regress.c | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/src/test/regress/pg_regress.c b/src/test/regress/pg_regress.c index 3a492449fb9..541ce8b33d3 100644 --- a/src/test/regress/pg_regress.c +++ b/src/test/regress/pg_regress.c @@ -450,7 +450,12 @@ convert_sourcefiles_in(char *source_subdir, char *dest_dir, char *dest_subdir, c * Windows. See pgsql-hackers discussion of 2008-01-18. */ if (directory_exists(testtablespace)) - rmtree(testtablespace, true); + if (!rmtree(testtablespace, true)) + { + fprintf(stderr, _("\n%s: could not remove test tablespace \"%s\": %s\n"), + progname, testtablespace, strerror(errno)); + exit(2); + } make_directory(testtablespace); #endif @@ -1152,6 +1157,9 @@ get_alternative_expectfile(const char *expectfile, int i) char *tmp = (char *) malloc(ssize); char *s = (char *) malloc(ssize); + if (!tmp || !s) + return NULL; + strcpy(tmp, expectfile); last_dot = strrchr(tmp, '.'); if (!last_dot) @@ -1258,8 +1266,18 @@ results_differ(const char *testname, const char *resultsfile, const char *defaul char *alt_expectfile; alt_expectfile = get_alternative_expectfile(expectfile, i); + if (!alt_expectfile) + { + fprintf(stderr, _("Unable to check secondary comparison files: %s\n"), + strerror(errno)); + exit(2); + } + if (!file_exists(alt_expectfile)) + { + free(alt_expectfile); continue; + } snprintf(cmd, sizeof(cmd), SYSTEMQUOTE "diff %s \"%s\" \"%s\" > \"%s\"" SYSTEMQUOTE, @@ -1268,6 +1286,7 @@ results_differ(const char *testname, const char *resultsfile, const char *defaul if (run_diff(cmd, diff) == 0) { unlink(diff); + free(alt_expectfile); return false; } @@ -2105,7 +2124,11 @@ regression_main(int argc, char *argv[], init_function ifunc, test_function tfunc if (directory_exists(temp_install)) { header(_("removing existing temp installation")); - rmtree(temp_install, true); + if (!rmtree(temp_install, true)) + { + fprintf(stderr, _("\n%s: could not remove temp installation \"%s\": %s\n"), progname, temp_install, strerror(errno)); + exit(2); + } } header(_("creating temporary installation")); |
