Skip to content

Commit 7f0f3ea

Browse files
apolukhineramongodb
authored andcommitted
CDRIVER-5834 Do not compare uninitialized bytes in _mongoc_server_description_equal (#1814)
Fix possible comparison of uninitialized bytes in `bson_error_t`. --------- Co-authored-by: Ezra Chung <[email protected]>
1 parent 35a4322 commit 7f0f3ea

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/libmongoc/src/mongoc/mongoc-server-description.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -1151,7 +1151,8 @@ _mongoc_server_description_equal (mongoc_server_description_t *sd1, mongoc_serve
11511151
return false;
11521152
}
11531153

1154-
if (0 != memcmp (&sd1->error, &sd2->error, sizeof (bson_error_t))) {
1154+
if (sd1->error.domain != sd2->error.domain || sd1->error.code != sd2->error.code ||
1155+
0 != strncmp (sd1->error.message, sd2->error.message, BSON_ERROR_BUFFER_SIZE)) {
11551156
return false;
11561157
}
11571158

0 commit comments

Comments
 (0)