From 667e73075f810841ff564b001280047e9c02cb49 Mon Sep 17 00:00:00 2001 From: Zachary Dremann Date: Fri, 20 Sep 2024 11:03:12 -0400 Subject: [PATCH] chore: update bindings to CRoaring 4.1.6 --- Cargo.lock | 2 +- README.md | 2 +- .../CRoaring/bindgen_bundled_version.rs | 4 +-- croaring-sys/CRoaring/roaring.c | 25 +++++++++++++++++-- croaring-sys/CRoaring/roaring.h | 6 ++--- croaring-sys/CRoaring/roaring.hh | 2 +- croaring-sys/Cargo.toml | 2 +- fuzz/Cargo.lock | 2 +- 8 files changed, 33 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b6e7fd5..c3136ab 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -189,7 +189,7 @@ dependencies = [ [[package]] name = "croaring-sys" -version = "4.1.4" +version = "4.1.6" dependencies = [ "cc", ] diff --git a/README.md b/README.md index db1dec1..30edc6c 100644 --- a/README.md +++ b/README.md @@ -127,7 +127,7 @@ Current documentation is available at https://docs.rs/croaring/latest/croaring/ ## CRoaring Version -This crate uses [CRoaring version `4.1.4`](https://github.com/RoaringBitmap/CRoaring/releases/tag/v4.1.4). +This crate uses [CRoaring version `4.1.6`](https://github.com/RoaringBitmap/CRoaring/releases/tag/v4.1.6). The version of this crate does not necessarily match the version of CRoaring: the major version of the crate is only incremented when there are breaking changes in the Rust API: It is possible (and has happened) that breaking changes in the CRoaring C API do not necessitate a major version bump in this crate. \ No newline at end of file diff --git a/croaring-sys/CRoaring/bindgen_bundled_version.rs b/croaring-sys/CRoaring/bindgen_bundled_version.rs index 63a94d5..5863268 100644 --- a/croaring-sys/CRoaring/bindgen_bundled_version.rs +++ b/croaring-sys/CRoaring/bindgen_bundled_version.rs @@ -1,9 +1,9 @@ /* automatically generated by rust-bindgen 0.70.1 */ -pub const ROARING_VERSION: &[u8; 6] = b"4.1.4\0"; +pub const ROARING_VERSION: &[u8; 6] = b"4.1.6\0"; pub const ROARING_VERSION_MAJOR: _bindgen_ty_1 = 4; pub const ROARING_VERSION_MINOR: _bindgen_ty_1 = 1; -pub const ROARING_VERSION_REVISION: _bindgen_ty_1 = 4; +pub const ROARING_VERSION_REVISION: _bindgen_ty_1 = 6; pub type _bindgen_ty_1 = ::core::ffi::c_uint; extern "C" { #[doc = " result might be undefined when input_num is zero"] diff --git a/croaring-sys/CRoaring/roaring.c b/croaring-sys/CRoaring/roaring.c index 878e53f..12434c3 100644 --- a/croaring-sys/CRoaring/roaring.c +++ b/croaring-sys/CRoaring/roaring.c @@ -1,5 +1,5 @@ // !!! DO NOT EDIT - THIS IS AN AUTO-GENERATED FILE !!! -// Created by amalgamation.sh on 2024-09-19T15:00:26Z +// Created by amalgamation.sh on 2024-09-20T14:21:41Z /* * The CRoaring project is under a dual license (Apache/MIT). @@ -24641,10 +24641,13 @@ roaring64_bitmap_t *roaring64_bitmap_portable_deserialize_safe( memcpy(&high32, buf, sizeof(high32)); buf += sizeof(high32); read_bytes += sizeof(high32); - if (high32 < previous_high32) { + // High 32 bits must be strictly increasing. + if (high32 <= previous_high32) { roaring64_bitmap_free(r); return NULL; } + previous_high32 = high32; + // Read the 32-bit Roaring bitmaps representing the least significant // bits of a set of elements. size_t bitmap32_size = roaring_bitmap_portable_deserialize_size( @@ -24663,6 +24666,24 @@ roaring64_bitmap_t *roaring64_bitmap_portable_deserialize_safe( buf += bitmap32_size; read_bytes += bitmap32_size; + // While we don't attempt to validate much, we must ensure that there + // is no duplication in the high 48 bits - inserting into the ART + // assumes (or UB) no duplicate keys. The top 32 bits must be unique + // because we check for strict increasing values of high32, but we + // must also ensure the top 16 bits within each 32-bit bitmap are also + // at least unique (we ensure they're strictly increasing as well, + // which they must be for a _valid_ bitmap, since it's cheaper to check) + int32_t last_bitmap_key = -1; + for (int i = 0; i < bitmap32->high_low_container.size; i++) { + uint16_t key = bitmap32->high_low_container.keys[i]; + if (key <= last_bitmap_key) { + roaring_bitmap_free(bitmap32); + roaring64_bitmap_free(r); + return NULL; + } + last_bitmap_key = key; + } + // Insert all containers of the 32-bit bitmap into the 64-bit bitmap. move_from_roaring32_offset(r, bitmap32, high32); roaring_bitmap_free(bitmap32); diff --git a/croaring-sys/CRoaring/roaring.h b/croaring-sys/CRoaring/roaring.h index 9afcc19..a3111cd 100644 --- a/croaring-sys/CRoaring/roaring.h +++ b/croaring-sys/CRoaring/roaring.h @@ -1,5 +1,5 @@ // !!! DO NOT EDIT - THIS IS AN AUTO-GENERATED FILE !!! -// Created by amalgamation.sh on 2024-09-19T15:00:26Z +// Created by amalgamation.sh on 2024-09-20T14:21:41Z /* * The CRoaring project is under a dual license (Apache/MIT). @@ -59,11 +59,11 @@ // /include/roaring/roaring_version.h automatically generated by release.py, do not change by hand #ifndef ROARING_INCLUDE_ROARING_VERSION #define ROARING_INCLUDE_ROARING_VERSION -#define ROARING_VERSION "4.1.4" +#define ROARING_VERSION "4.1.6" enum { ROARING_VERSION_MAJOR = 4, ROARING_VERSION_MINOR = 1, - ROARING_VERSION_REVISION = 4 + ROARING_VERSION_REVISION = 6 }; #endif // ROARING_INCLUDE_ROARING_VERSION // clang-format on/* end file include/roaring/roaring_version.h */ diff --git a/croaring-sys/CRoaring/roaring.hh b/croaring-sys/CRoaring/roaring.hh index 62df063..8422322 100644 --- a/croaring-sys/CRoaring/roaring.hh +++ b/croaring-sys/CRoaring/roaring.hh @@ -1,5 +1,5 @@ // !!! DO NOT EDIT - THIS IS AN AUTO-GENERATED FILE !!! -// Created by amalgamation.sh on 2024-09-19T15:00:26Z +// Created by amalgamation.sh on 2024-09-20T14:21:41Z /* * The CRoaring project is under a dual license (Apache/MIT). diff --git a/croaring-sys/Cargo.toml b/croaring-sys/Cargo.toml index 6f17629..ca7a4d3 100644 --- a/croaring-sys/Cargo.toml +++ b/croaring-sys/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "croaring-sys" -version = "4.1.4" +version = "4.1.6" edition = "2021" authors = ["croaring-rs developers"] license = "Apache-2.0" diff --git a/fuzz/Cargo.lock b/fuzz/Cargo.lock index 9e63e79..af921b0 100644 --- a/fuzz/Cargo.lock +++ b/fuzz/Cargo.lock @@ -51,7 +51,7 @@ dependencies = [ [[package]] name = "croaring-sys" -version = "4.1.4" +version = "4.1.6" dependencies = [ "cc", ]