SERVER-119317 Improve object lifecycle of MD5 hash state (#47995)

GitOrigin-RevId: 5d25c835745d06f712320b6cdae9d50b7b43663e
This commit is contained in:
Spencer Jackson 2026-02-18 14:54:36 -08:00 committed by MongoDB Bot
parent e5bb279f33
commit 32a732a9b6
3 changed files with 27 additions and 1 deletions

View File

@ -21,6 +21,8 @@
#
last-continuous:
all:
- test_file: jstests/core/administrative/filemd5.js
ticket: SERVER-119317
- test_file: jstests/core/index/elemmatch_index.js
ticket: SERVER-108945
- test_file: jstests/replsets/malformed_heartbeat_request.js
@ -525,6 +527,8 @@ last-continuous:
suites: null
last-lts:
all:
- test_file: jstests/core/administrative/filemd5.js
ticket: SERVER-119317
- test_file: jstests/core/index/elemmatch_index.js
ticket: SERVER-108945
- test_file: jstests/replsets/malformed_heartbeat_request.js

View File

@ -20,4 +20,25 @@ assert.commandFailedWithCode(db.runCommand({filemd5: 1, root: "fs", partialOk: 1
assert.commandWorked(db.fs.chunks.insert({files_id: 2, n: 0}));
assert.commandFailedWithCode(db.runCommand({filemd5: 2, root: "fs"}), 50848);
assert.commandWorked(db.fs.chunks.update({files_id: 2, n: 0}, {$set: {data: 5}}));
assert.commandFailedWithCode(db.runCommand({filemd5: 2, root: "fs"}), 50849);
assert.commandFailedWithCode(db.runCommand({filemd5: 2, root: "fs"}), 50849);
{
const result = assert.commandWorked(
db.runCommand({
filemd5: ObjectId("000000000000000000000000"),
root: "fs",
partialOk: true,
}),
);
assert(result.md5state !== undefined,
"Expected md5state in filemd5 response with partialOk: true");
const hex = result.md5state.hex();
const totalBytes = hex.length / 2;
assert.gt(totalBytes, 100, "md5state expected to be larger than 100 bytes");
const checkFromByte = 100;
const paddingHex = hex.substring(checkFromByte * 2);
const allZeros = "0".repeat(paddingHex.length);
assert.eq(paddingHex, allZeros, "md5state expected to be zero padded");
}

View File

@ -35,6 +35,7 @@
namespace mongo {
void md5_init_state(md5_state_t* pms) {
memset(pms, 0, sizeof(md5_state_t));
md5_init(pms);
}