Skip to content

mp_from_sbin size check #595

Closed
Closed

Description

@k321

mp_err mp_from_sbin(mp_int *a, const uint8_t *buf, size_t size)

Any call with size <= 0 through this API may exhaust process memory

Suggest to return early if size <= 0

Activity

  1. czurnieden commented on Apr 20, 2026

    @czurnieden
    Contributor

    The type of size is size_t which is typically unsigned. Too much handholding, propose NOTABUG

  2. sjaeckel commented on Apr 20, 2026

    @sjaeckel
    Member

    The type of size is size_t which is typically unsigned.

    So there's no negative size possible, but the case for size == 0 seems to be valid.

    if ((err = mp_from_ubin(a, buf + 1, size - 1u)) != MP_OKAY) {

  3. czurnieden commented on Apr 20, 2026

    @czurnieden
    Contributor

    You are too nice for this world! ;-)
    Added a check in #597

  4. linked a pull request that will close this issueCheck size of argument #597on Apr 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions