The branch main has been updated by emaste:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=250db717b24d084c0a3193226a79b73a69fbfe0f

commit 250db717b24d084c0a3193226a79b73a69fbfe0f
Author:     Ed Maste <[email protected]>
AuthorDate: 2026-08-21 14:31:25 +0000
Commit:     Ed Maste <[email protected]>
CommitDate: 2026-08-21 14:53:45 +0000

    libusb: Add an XXX comment for possible duplicate callback IDs
    
    If next_callback_id wraps we could end up with two callbacks with the
    same ID.  I recommitted the original change despite this issue in order
    to fix the libusb API as soon as possible after SHLIB_MAJOR was bumped
    in commit 527a82474cb3 (libusb: versioning symbols).
    
    It's very unlikely in practice that software will register and
    deregister a sufficient number of callbacks to trigger this, but it is
    a real issue to be fixed in a subsequent commit.
    
    Sponsored by:   The FreeBSD Foundation
---
 lib/libusb/libusb10_hotplug.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/libusb/libusb10_hotplug.c b/lib/libusb/libusb10_hotplug.c
index ee0fea82a8fe..ae7e8d168948 100644
--- a/lib/libusb/libusb10_hotplug.c
+++ b/lib/libusb/libusb10_hotplug.c
@@ -375,6 +375,7 @@ int libusb_hotplug_register_callback(libusb_context *ctx,
        handle->fn = cb_fn;
        handle->user_data = user_data;
        CTX_LOCK(ctx);
+       /* XXX This could result in duplicate callback IDs, and is UB. */
        if ((handle->id = ctx->next_callback_id++) < 0)
                handle->id = ctx->next_callback_id = 1;
        CTX_UNLOCK(ctx);

Reply via email to