Skip to content

Commit dcfd5c6

Browse files
nathantfrankMongoDB Bot
authored and
MongoDB Bot
committed
SERVER-102596: upgrade libbson to 1.28.1 (#34206)
GitOrigin-RevId: 86e52f88587862f7a0d73e7d11ad01fee416646d
1 parent 491a4a8 commit dcfd5c6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+253
-119
lines changed

README.third_party.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ a notice will be included in
5050
| [LibTomCrypt] | WTFPL, Public Domain | 1.18.2 |||
5151
| [libunwind/libunwind] | MIT | v1.8.1 | ||
5252
| [linenoise] | BSD-2-Clause | Unknown | ||
53-
| [MongoDB C Driver] | Apache-2.0 | 1.27.6 |||
53+
| [MongoDB C Driver] | Apache-2.0 | 1.28.1 |||
5454
| [Mozilla Firefox] | MPL-2.0 | 128.8.0esr | unknown ||
5555
| [nlohmann-json] | MIT | 3.11.3 || |
5656
| [nlohmann.json.decomposed] | MIT | 3.10.5 | unknown | |

bazel/mongo_src_rules.bzl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1574,7 +1574,7 @@ def force_includes_hdr(package_name, name):
15741574

15751575
return []
15761576

1577-
# TODO(SERVER-102596): Stop including this flag when ASP is able to upgrade mongoc and mongocxx
1577+
# TODO(SERVER-103006): Stop including this flag when ASP is able to upgrade mongoc and mongocxx
15781578
STREAMS_THIRD_PARTY_DIR = "src/mongo/db/modules/enterprise/src/streams/third_party"
15791579

15801580
def package_specific_copt(package_name):

sbom.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1191,15 +1191,15 @@
11911191
"name": "Organization: github"
11921192
},
11931193
"name": "MongoDB C Driver",
1194-
"version": "1.27.6",
1194+
"version": "1.28.1",
11951195
"licenses": [
11961196
{
11971197
"license": {
11981198
"id": "Apache-2.0"
11991199
}
12001200
}
12011201
],
1202-
"purl": "pkg:github/mongodb/mongo-c-driver@1.27.6",
1202+
"purl": "pkg:github/mongodb/mongo-c-driver@1.28.1",
12031203
"properties": [
12041204
{
12051205
"name": "internal:team_responsible",

src/third_party/libbson/dist/src/common/common-b64-private.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2018-present MongoDB Inc.
2+
* Copyright 2009-present MongoDB, Inc.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

src/third_party/libbson/dist/src/common/common-macros-private.h

+43
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
/*
2+
* Copyright 2009-present MongoDB, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
116

217
#include "common-prelude.h"
318

@@ -12,4 +27,32 @@
1227
#define MONGOC_DEBUG_ASSERT(statement) ((void) 0)
1328
#endif
1429

30+
// `MC_ENABLE_CONVERSION_WARNING_BEGIN` enables -Wconversion to check for potentially unsafe integer conversions.
31+
// The `bson_in_range_*` functions can help address these warnings by ensuring a cast is within bounds.
32+
#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) // gcc 4.6 added support for "diagnostic push".
33+
#define MC_ENABLE_CONVERSION_WARNING_BEGIN \
34+
_Pragma ("GCC diagnostic push") _Pragma ("GCC diagnostic warning \"-Wconversion\"")
35+
#define MC_ENABLE_CONVERSION_WARNING_END _Pragma ("GCC diagnostic pop")
36+
#elif defined(__clang__)
37+
#define MC_ENABLE_CONVERSION_WARNING_BEGIN \
38+
_Pragma ("clang diagnostic push") _Pragma ("clang diagnostic warning \"-Wconversion\"")
39+
#define MC_ENABLE_CONVERSION_WARNING_END _Pragma ("clang diagnostic pop")
40+
#else
41+
#define MC_ENABLE_CONVERSION_WARNING_BEGIN
42+
#define MC_ENABLE_CONVERSION_WARNING_END
1543
#endif
44+
45+
// Disable the -Wcast-function-type-strict warning.
46+
#define MC_DISABLE_CAST_FUNCTION_TYPE_STRICT_WARNING_BEGIN
47+
#define MC_DISABLE_CAST_FUNCTION_TYPE_STRICT_WARNING_END
48+
#if defined(__clang__)
49+
#if __has_warning("-Wcast-function-type-strict")
50+
#undef MC_DISABLE_CAST_FUNCTION_TYPE_STRICT_WARNING_BEGIN
51+
#undef MC_DISABLE_CAST_FUNCTION_TYPE_STRICT_WARNING_END
52+
#define MC_DISABLE_CAST_FUNCTION_TYPE_STRICT_WARNING_BEGIN \
53+
_Pragma ("clang diagnostic push") _Pragma ("clang diagnostic ignored \"-Wcast-function-type-strict\"")
54+
#define MC_DISABLE_CAST_FUNCTION_TYPE_STRICT_WARNING_END _Pragma ("clang diagnostic pop")
55+
#endif // __has_warning("-Wcast-function-type-strict")
56+
#endif // defined(__clang__)
57+
58+
#endif /* COMMON_MACROS_PRIVATE_H */

src/third_party/libbson/dist/src/common/common-md5-private.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2018-present MongoDB, Inc.
2+
* Copyright 2009-present MongoDB, Inc.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

src/third_party/libbson/dist/src/common/common-prelude.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2018-present MongoDB, Inc.
2+
* Copyright 2009-present MongoDB, Inc.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

src/third_party/libbson/dist/src/common/common-thread-private.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2013-present MongoDB, Inc.
2+
* Copyright 2009-present MongoDB, Inc.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

src/third_party/libbson/dist/src/common/common-thread.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020-present MongoDB, Inc.
2+
* Copyright 2009-present MongoDB, Inc.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -24,7 +24,7 @@ mcommon_thread_create (bson_thread_t *thread, BSON_THREAD_FUN_TYPE (func), void
2424
{
2525
BSON_ASSERT_PARAM (thread);
2626
BSON_ASSERT_PARAM (func);
27-
BSON_ASSERT (arg || true); // optional.
27+
BSON_OPTIONAL_PARAM (arg); // optional.
2828
return pthread_create (thread, NULL, func, arg);
2929
}
3030
int
@@ -47,7 +47,7 @@ mcommon_thread_create (bson_thread_t *thread, BSON_THREAD_FUN_TYPE (func), void
4747
{
4848
BSON_ASSERT_PARAM (thread);
4949
BSON_ASSERT_PARAM (func);
50-
BSON_ASSERT (arg || true); // optional.
50+
BSON_OPTIONAL_PARAM (arg); // optional.
5151

5252
*thread = (HANDLE) _beginthreadex (NULL, 0, func, arg, 0, NULL);
5353
if (0 == *thread) {

src/third_party/libbson/dist/src/libbson/NEWS

+30
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,33 @@
1+
libbson 1.28.1
2+
==============
3+
4+
Fixes:
5+
6+
* Fix large string handling in `bson_string_truncate`.
7+
* Fix possible crash in `bson_value_copy`.
8+
9+
10+
Thanks to everyone who contributed to the development of this release.
11+
12+
* Joshua Siegel
13+
* Kevin Albertson
14+
15+
16+
17+
libbson 1.28.0
18+
==============
19+
20+
New features:
21+
22+
* Add `bson_validate_with_error_and_offset`.
23+
24+
Build Configuration:
25+
26+
* Remove automatic ccache detection and usage (CCache.cmake).
27+
* Set [`CMAKE_<LANG>_COMPILER_LAUNCHER`](https://cmake.org/cmake/help/latest/envvar/CMAKE_LANG_COMPILER_LAUNCHER.html) to build with ccache.
28+
* Remove `MONGO_USE_CCACHE` (no longer applicable; see above).
29+
30+
131
libbson 1.27.6
232
==============
333

src/third_party/libbson/dist/src/libbson/libbson.rc.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ BEGIN
3434
VALUE "OriginalFilename", BSON_OUTPUT_BASENAME "-" BSON_API_VERSION ".dll"
3535
VALUE "ProductName", "MongoDB C Driver"
3636
VALUE "ProductVersion", BSON_VERSION_S
37-
VALUE "LegalCopyright", "Copyright (C) 2013-present MongoDB, Inc."
37+
VALUE "LegalCopyright", "Copyright 2009-present MongoDB, Inc."
3838
END
3939
END
4040
BLOCK "VarFileInfo"

src/third_party/libbson/dist/src/libbson/src/bson/bcon.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* @brief BCON (BSON C Object Notation) Implementation
44
*/
55

6-
/* Copyright 2009-2013 MongoDB, Inc.
6+
/* Copyright 2009-present MongoDB, Inc.
77
*
88
* Licensed under the Apache License, Version 2.0 (the "License");
99
* you may not use this file except in compliance with the License.

src/third_party/libbson/dist/src/libbson/src/bson/bcon.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
#include <bson/bson-prelude.h>
77

8-
/* Copyright 2009-2013 MongoDB, Inc.
8+
/* Copyright 2009-present MongoDB, Inc.
99
*
1010
* Licensed under the Apache License, Version 2.0 (the "License");
1111
* you may not use this file except in compliance with the License.

src/third_party/libbson/dist/src/libbson/src/bson/bson-atomic.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014 MongoDB, Inc.
2+
* Copyright 2009-present MongoDB, Inc.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

src/third_party/libbson/dist/src/libbson/src/bson/bson-atomic.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2013-2014 MongoDB, Inc.
2+
* Copyright 2009-present MongoDB, Inc.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -187,6 +187,7 @@ enum bson_memory_order {
187187
BSON_UNREACHABLE ("Invalid bson_memory_order value"); \
188188
}) \
189189
BSON_IF_GNU_LEGACY_ATOMICS ({ \
190+
BSON_UNUSED (order); \
190191
__sync_synchronize (); \
191192
return *a; \
192193
}) \
@@ -213,7 +214,7 @@ enum bson_memory_order {
213214
default: \
214215
BSON_UNREACHABLE ("Invalid bson_memory_order value"); \
215216
}) \
216-
BSON_IF_GNU_LEGACY_ATOMICS (return __sync_val_compare_and_swap (a, *a, value);) \
217+
BSON_IF_GNU_LEGACY_ATOMICS (BSON_UNUSED (ord); return __sync_val_compare_and_swap (a, *a, value);) \
217218
} \
218219
\
219220
static BSON_INLINE Type bson_atomic_##NamePart##_compare_exchange_strong ( \

src/third_party/libbson/dist/src/libbson/src/bson/bson-clock.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2013 MongoDB, Inc.
2+
* Copyright 2009-present MongoDB, Inc.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

src/third_party/libbson/dist/src/libbson/src/bson/bson-clock.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014 MongoDB, Inc.
2+
* Copyright 2009-present MongoDB, Inc.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

src/third_party/libbson/dist/src/libbson/src/bson/bson-cmp.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2022 MongoDB, Inc.
2+
* Copyright 2009-present MongoDB, Inc.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

src/third_party/libbson/dist/src/libbson/src/bson/bson-compat.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2013 MongoDB, Inc.
2+
* Copyright 2009-present MongoDB, Inc.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -36,11 +36,11 @@
3636

3737

3838
#ifdef BSON_OS_WIN32
39-
#if defined(_WIN32_WINNT) && (_WIN32_WINNT < 0x0600)
39+
#if defined(_WIN32_WINNT) && (_WIN32_WINNT < 0x0601)
4040
#undef _WIN32_WINNT
4141
#endif
4242
#ifndef _WIN32_WINNT
43-
#define _WIN32_WINNT 0x0600
43+
#define _WIN32_WINNT 0x0601
4444
#endif
4545
#ifndef NOMINMAX
4646
#define NOMINMAX

src/third_party/libbson/dist/src/libbson/src/bson/bson-config.h.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2018-present MongoDB, Inc.
2+
* Copyright 2009-present MongoDB, Inc.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

src/third_party/libbson/dist/src/libbson/src/bson/bson-context-private.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014 MongoDB, Inc.
2+
* Copyright 2009-present MongoDB, Inc.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

src/third_party/libbson/dist/src/libbson/src/bson/bson-context.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2013 MongoDB, Inc.
2+
* Copyright 2009-present MongoDB, Inc.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

src/third_party/libbson/dist/src/libbson/src/bson/bson-context.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2013 MongoDB, Inc.
2+
* Copyright 2009-present MongoDB, Inc.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

src/third_party/libbson/dist/src/libbson/src/bson/bson-decimal128.c

+9-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
/*
3-
* Copyright 2015 MongoDB, Inc.
3+
* Copyright 2009-present MongoDB, Inc.
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.
@@ -269,7 +269,9 @@ bson_decimal128_to_string (const bson_decimal128_t *dec, /* IN */
269269
}
270270
/* Exponent */
271271
*(str_out++) = 'E';
272-
bson_snprintf (str_out, 6, "%+d", scientific_exponent);
272+
// Truncation is OK.
273+
int req = bson_snprintf (str_out, 6, "%+d", scientific_exponent);
274+
BSON_ASSERT (req > 0);
273275
} else {
274276
/* Regular format with no decimal place */
275277
if (exponent >= 0) {
@@ -280,8 +282,11 @@ bson_decimal128_to_string (const bson_decimal128_t *dec, /* IN */
280282
} else {
281283
int32_t radix_position = significand_digits + exponent;
282284

285+
// Reserve space for null terminator.
286+
const int available_bytes = BSON_DECIMAL128_STRING - 1;
287+
283288
if (radix_position > 0) { /* non-zero digits before radix */
284-
for (int32_t i = 0; i < radix_position && (str_out - str) < BSON_DECIMAL128_STRING; i++) {
289+
for (int32_t i = 0; i < radix_position && (str_out - str) < available_bytes; i++) {
285290
*(str_out++) = *(significand_read++) + '0';
286291
}
287292
} else { /* leading zero before radix point */
@@ -294,7 +299,7 @@ bson_decimal128_to_string (const bson_decimal128_t *dec, /* IN */
294299
}
295300

296301
for (uint32_t i = 0; bson_cmp_greater_us (significand_digits - i, BSON_MAX (radix_position - 1, 0)) &&
297-
(str_out - str) < BSON_DECIMAL128_STRING;
302+
(str_out - str) < available_bytes;
298303
i++) {
299304
*(str_out++) = *(significand_read++) + '0';
300305
}

src/third_party/libbson/dist/src/libbson/src/bson/bson-decimal128.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015 MongoDB, Inc.
2+
* Copyright 2009-present MongoDB, Inc.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

src/third_party/libbson/dist/src/libbson/src/bson/bson-endian.h

+2-12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2013 MongoDB, Inc.
2+
* Copyright 2009-present MongoDB, Inc.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -20,11 +20,6 @@
2020
#ifndef BSON_ENDIAN_H
2121
#define BSON_ENDIAN_H
2222

23-
24-
#if defined(__sun)
25-
#include <sys/byteorder.h>
26-
#endif
27-
2823
#include <bson/bson-config.h>
2924
#include <bson/bson-macros.h>
3025
#include <bson/bson-compat.h>
@@ -36,12 +31,7 @@ BSON_BEGIN_DECLS
3631
#define BSON_BIG_ENDIAN 4321
3732
#define BSON_LITTLE_ENDIAN 1234
3833

39-
40-
#if defined(__sun)
41-
#define BSON_UINT16_SWAP_LE_BE(v) BSWAP_16 ((uint16_t) v)
42-
#define BSON_UINT32_SWAP_LE_BE(v) BSWAP_32 ((uint32_t) v)
43-
#define BSON_UINT64_SWAP_LE_BE(v) BSWAP_64 ((uint64_t) v)
44-
#elif defined(__clang__) && defined(__clang_major__) && defined(__clang_minor__) && (__clang_major__ >= 3) && \
34+
#if defined(__clang__) && defined(__clang_major__) && defined(__clang_minor__) && (__clang_major__ >= 3) && \
4535
(__clang_minor__ >= 1)
4636
#if __has_builtin(__builtin_bswap16)
4737
#define BSON_UINT16_SWAP_LE_BE(v) __builtin_bswap16 (v)

src/third_party/libbson/dist/src/libbson/src/bson/bson-error.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2013 MongoDB, Inc.
2+
* Copyright 2009-present MongoDB, Inc.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

src/third_party/libbson/dist/src/libbson/src/bson/bson-error.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2013 MongoDB, Inc.
2+
* Copyright 2009-present MongoDB, Inc.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

0 commit comments

Comments
 (0)