diff options
author | Alison Felizzi <alison.felizzi@mongodb.com> | 2021-11-25 04:24:27 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-11-25 04:56:29 +0000 |
commit | ff3c2a3ffa3775b1e455852b4cf89ebf0af1db3c (patch) | |
tree | f4bb2e3f0d9d18c864a5cb25072b4d7fa20e8bcf | |
parent | 1ce7fb6b75cb870696b5fcd00ede8ac41406d53e (diff) | |
download | mongo-ff3c2a3ffa3775b1e455852b4cf89ebf0af1db3c.tar.gz |
Import wiredtiger: a7b548cc6c470847c09eae6236a6cf209ba239f5 from branch mongodb-master
ref: 0f37ab9c11..a7b548cc6c
for: 5.2.0
WT-8389 Coverity analysis defect 121099: Untrusted loop bound
-rw-r--r-- | src/third_party/wiredtiger/import.data | 2 | ||||
-rw-r--r-- | src/third_party/wiredtiger/test/format/config.c | 46 |
2 files changed, 29 insertions, 19 deletions
diff --git a/src/third_party/wiredtiger/import.data b/src/third_party/wiredtiger/import.data index 23c83e87688..5385c731bb0 100644 --- a/src/third_party/wiredtiger/import.data +++ b/src/third_party/wiredtiger/import.data @@ -2,5 +2,5 @@ "vendor": "wiredtiger", "github": "wiredtiger/wiredtiger.git", "branch": "mongodb-master", - "commit": "0f37ab9c11fef6a3da0ad42257ac6f6e549bd0d1" + "commit": "a7b548cc6c470847c09eae6236a6cf209ba239f5" } diff --git a/src/third_party/wiredtiger/test/format/config.c b/src/third_party/wiredtiger/test/format/config.c index e2f65000e44..b17c0aa9c2a 100644 --- a/src/third_party/wiredtiger/test/format/config.c +++ b/src/third_party/wiredtiger/test/format/config.c @@ -1250,7 +1250,7 @@ void config_file(const char *name) { FILE *fp; - char buf[256], *p, *t; + char buf[256], *p; /* * Turn off multi-table configuration for all configuration files, for backward compatibility. @@ -1266,29 +1266,39 @@ config_file(const char *name) testutil_die(errno, "fopen: %s", name); /* - * Skip leading Evergreen timestamps by skipping up to a closing brace and following whitespace. - * This is a little fragile: we're in trouble if Evergreen changes its timestamp format or if - * this program includes closing braces in its commands. + * Skip whitespace leading up to the configuration. Skip Evergreen timestamps by skipping a pair + * of enclosing braces and trailing whitespace. This is fragile: we're in trouble if Evergreen + * changes its timestamp format. */ while (fgets(buf, sizeof(buf), fp) != NULL) { - for (p = t = buf; *p != '\0'; ++p) { - if (*p == '\n') { /* Configuration end. */ + /* Replace any newline character. */ + for (p = buf; *p != '\0'; ++p) + if (*p == '\n') { *p = '\0'; break; } - if (*p == '#') { /* Comment */ - t = p; + + /* Skip any leading whitespace. */ + for (p = buf; *p != '\0'; ++p) + if (!isblank(*p)) break; - } - if (t == buf && *p == ']') { /* Closing brace, configuration starts after it. */ - while (isblank((unsigned char)*++p)) - ; - t = p--; - } - } - if (*t == '\0' || *t == '#') - continue; - config_single(NULL, t, true); + + /* Skip any Evergreen timestamp. */ + if (*p == '[') + for (; *p != '\0'; ++p) + if (*p == ']') { + ++p; + break; + } + + /* Skip any trailing whitespace. */ + for (; *p != '\0'; ++p) + if (!isblank(*p)) + break; + + /* Skip any comments or empty lines. */ + if (*p != '\0' && *p != '#') + config_single(NULL, p, true); } fclose_and_clear(&fp); } |