From b929ccd58eef0e2100c4ff287122fe43846562f5 Mon Sep 17 00:00:00 2001 From: Etienne Petrel Date: Tue, 27 Sep 2022 17:07:58 +0000 Subject: Import wiredtiger: 441b9a3769271ac32088dce23e1b9a4c10c31790 from branch mongodb-master ref: 4afd038167..441b9a3769 for: 6.2.0-rc0 WT-9676 Coverity analysis defect 126347/123712: Resource leak (#8303) --- .../wiredtiger/ext/storage_sources/dir_store/dir_store.c | 11 ++++++++--- src/third_party/wiredtiger/import.data | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/third_party/wiredtiger/ext/storage_sources/dir_store/dir_store.c b/src/third_party/wiredtiger/ext/storage_sources/dir_store/dir_store.c index 390f4866466..5c70b5701b7 100644 --- a/src/third_party/wiredtiger/ext/storage_sources/dir_store/dir_store.c +++ b/src/third_party/wiredtiger/ext/storage_sources/dir_store/dir_store.c @@ -318,9 +318,12 @@ dir_store_get_directory(const char *home, const char *s, ssize_t len, bool creat dirname = strndup(s, (size_t)len + 1); /* Room for null */ else { buflen = (size_t)len + strlen(home) + 2; /* Room for slash, null */ - if ((dirname = malloc(buflen)) != NULL) - if (snprintf(dirname, buflen, "%s/%.*s", home, (int)len, s) >= (int)buflen) + if ((dirname = malloc(buflen)) != NULL) { + if (snprintf(dirname, buflen, "%s/%.*s", home, (int)len, s) >= (int)buflen) { + free(dirname); return (EINVAL); + } + } } if (dirname == NULL) return (ENOMEM); @@ -398,8 +401,10 @@ dir_store_path(WT_FILE_SYSTEM *file_system, const char *dir, const char *name, c len = strlen(dir) + strlen(name) + 2; if ((p = malloc(len)) == NULL) return (dir_store_err(FS2DS(file_system), NULL, ENOMEM, "dir_store_path")); - if (snprintf(p, len, "%s/%s", dir, name) >= (int)len) + if (snprintf(p, len, "%s/%s", dir, name) >= (int)len) { + free(p); return (dir_store_err(FS2DS(file_system), NULL, EINVAL, "overflow sprintf")); + } *pathp = p; return (ret); } diff --git a/src/third_party/wiredtiger/import.data b/src/third_party/wiredtiger/import.data index 06b0b9dc3fe..02b9d0f7a4b 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": "4afd038167adcdefefc2a8673f355d941226517f" + "commit": "441b9a3769271ac32088dce23e1b9a4c10c31790" } -- cgit v1.2.1