Skip to content

Is it safe to pass negative lengths to functions? #67

@newpavlov

Description

@newpavlov

random_get has the following signature:

pub fn random_get(arg0: i32, arg1: i32) -> i32;

Meanwhile in the witx files it's defined as:

(typename $size u32)

  (@interface func (export "random_get")
    ;;; The buffer to fill with random data.
    (param $buf (@witx pointer u8))
    (param $buf_len $size)
    (result $error (expected (error $errno)))
  )

Assuming buffer length is casted from usize to i32, would it work correctly? Note that according to this comment:

none of our 3 WASM environments (Emscripten, wasi-libc, wasm32-unknown-unknown) enforce isize::MAX right now

Is there a reason why all arguments and return values are defined use i32 instead of more descriptive types used in the witx files?

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