summaryrefslogtreecommitdiff
path: root/test/recovery/truncated-log.c
diff options
context:
space:
mode:
authorKeith Bostic <keith.bostic@mongodb.com>2017-01-18 21:05:06 -0500
committerSulabh Mahajan <sulabh.mahajan@mongodb.com>2017-01-19 13:05:06 +1100
commit91dd1fa489cab34a40e3f0115fe6771326e9c410 (patch)
treefceb27de9cc55311b844f69e6e891e45b267cca5 /test/recovery/truncated-log.c
parent25a7c8aae547b7a0c50081656935c663c640a9f0 (diff)
downloadmongo-91dd1fa489cab34a40e3f0115fe6771326e9c410.tar.gz
WT-3134 Coverity scan reports 1368529 and 1368528 (#3251)
* Coverity complains: CID 1368529: Security best practices violations (TOCTOU) Calling function "fopen" that uses "fname" after a check function. This can cause a time-of-check, time-of-use race condition. We're doing: snprintf(buffer); stat(buffer); snprintf(buffer); fopen(buffer); and I think Coverity is ignoring the second snprintf(), and is complaining about a stat followed by an fopen some number of lines of code later. It's simple enough to give the two calls their own buffers, hopefully that will keep Coverity quiet. Use 1024 as the size of a path instead of 512, (that's the traditional MAXPATHLEN value). Use sizeof(home) in calls to testutil_work_dir_from_path() so we don't accidentally diverge from the declared size. Clean up an error call, there's no need for two error messages. * Coverity complains: CID 1368528: (DEADCODE) Execution cannot reach the expression "","" inside this statement: "pos += (uint32_t)snprintf(c...". Replace boolean variable with a "const char *" that's set to either an empty string or a comma, removing the need for the test. Use size_t as the size of an object in memory, not a uint32_t. Don't declare variables in block scope. Assignment operators are the lowest priority operator (well, except for comma), don't bother declaring the order of evalution for an assignment operator. strlen() returns a size_t length, don't evaluate it as a boolean.
Diffstat (limited to 'test/recovery/truncated-log.c')
-rw-r--r--test/recovery/truncated-log.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/test/recovery/truncated-log.c b/test/recovery/truncated-log.c
index c265263d44c..6a142b8e710 100644
--- a/test/recovery/truncated-log.c
+++ b/test/recovery/truncated-log.c
@@ -35,7 +35,7 @@
#define snprintf _snprintf
#endif
-static char home[512]; /* Program working dir */
+static char home[1024]; /* Program working dir */
static const char *progname; /* Program name */
static const char * const uri = "table:main";
@@ -290,7 +290,7 @@ main(int argc, char *argv[])
if (argc != 0)
usage();
- testutil_work_dir_from_path(home, 512, working_dir);
+ testutil_work_dir_from_path(home, sizeof(home), working_dir);
testutil_make_work_dir(home);
/*