Skip to content

Fix SDP integer overflow and inverted NULL check in gatt_db clone#15

Open
TuNaiChao wants to merge 2 commits into
deepin-community:masterfrom
TuNaiChao:my-fix
Open

Fix SDP integer overflow and inverted NULL check in gatt_db clone#15
TuNaiChao wants to merge 2 commits into
deepin-community:masterfrom
TuNaiChao:my-fix

Conversation

@TuNaiChao

@TuNaiChao TuNaiChao commented Jun 23, 2026

Copy link
Copy Markdown

Fix SDP integer overflow and inverted NULL check in gatt_db clone

适配v25系统,修复SDP解析整数溢出与gatt_db克隆NULL检查反转的问题

  1. 修复 sdp_extract_seqtype() 中的整数溢出:
    从数据包读取的 uint32_t size 值被直接赋值给 int 类型的 *size,
    未做范围检查。恶意构造的 SDP 数据包 size 超过 INT_MAX 时会
    导致整数溢出,得到错误或负数的 size 值,可能在后续解析过程中
    引发越界访问。修复为在赋值前校验 uint32_t 值不超过 INT_MAX,
    超限时返回错误,避免溢出。

    Fixed integer overflow in sdp_extract_seqtype() where the uint32_t
    size value read from the packet was directly assigned to an int
    without range checking. A crafted SDP packet with a size exceeding
    INT_MAX would overflow the int, leading to a wrong/negative size
    value and potential out-of-bounds access during parsing.

  2. 修复 btd_device_set_gatt_db() 中的 NULL 检查逻辑反转:
    gatt_db_clone() 在失败时返回 NULL,原条件判断逻辑反转:克隆成功
    (非NULL)时反而提前返回并跳过设备 GATT 数据库的交换,克隆失败
    (NULL)时却继续向下执行,导致后续解引用空指针。修复为仅在克隆
    失败时才提前返回,克隆成功时正常进行数据库交换。

    Fixed inverted NULL check in btd_device_set_gatt_db() since
    gatt_db_clone() returns NULL on failure. The old condition bailed
    out early on a successful clone and fell through on failure,
    dereferencing a NULL pointer a few lines below.

gatt_db_clone() returns NULL on failure. The old condition bailed out
early on a successful clone and fell through on failure, dereferencing
a NULL pointer a few lines below.

适配v25系统,修复gatt_db克隆时NULL检查逻辑反转的问题
gatt_db_clone() 在失败时返回 NULL,原条件判断逻辑反转:克隆成功
(非NULL)时反而提前返回并跳过设备 GATT 数据库的交换,克隆失败
(NULL)时却继续向下执行,导致后续解引用空指针。修复为仅在克隆
失败时才提前返回,克隆成功时正常进行数据库交换。
@github-actions

github-actions Bot commented Jun 23, 2026

Copy link
Copy Markdown

TAG Bot

TAG: 5.85-3deepin8
EXISTED: no
DISTRIBUTION: unstable

@deepin-ci-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign yukarichiba for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@deepin-ci-robot

Copy link
Copy Markdown
Contributor

Hi @TuNaiChao. Thanks for your PR.

I'm waiting for a deepin-community member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

size value read from the packet was directly assigned to an int
without range checking. A crafted SDP packet with a size exceeding
INT_MAX would overflow the int, leading to a wrong/negative size
value and potential out-of-bounds access during parsing.

适配v25系统,修复SDP解析中sdp_extract_seqtype整数溢出的问题
从数据包读取的 uint32_t size 值被直接赋值给 int 类型的 *size,
未做范围检查。当恶意构造的 SDP 数据包 size 超过 INT_MAX 时会
导致整数溢出,得到错误或负数的 size 值,可能在后续解析过程中
引发越界访问。修复为在赋值前校验 uint32_t 值不超过 INT_MAX,
超限时返回错误,避免溢出。
@TuNaiChao TuNaiChao changed the title fix inverted NULL check in gatt_db clone Fix SDP integer overflow and inverted NULL check in gatt_db clone Jun 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants