bytecodealliance / wasm-micro-runtime

WebAssembly Micro Runtime (WAMR)
Apache License 2.0
4.94k stars 623 forks source link

This value might overflow 64 bit int #3614

Open g0djan opened 4 months ago

g0djan commented 4 months ago

https://github.com/bytecodealliance/wasm-micro-runtime/blob/1b1ec715e9b16c23f146333de846fb0285ec2401/core/iwasm/libraries/lib-socket/src/wasi/wasi_socket_ext.c#L582

loganek commented 4 months ago

Thanks, I think this value indeed can overflow, but I'm not sure there's much we can do about it - we could potentially saturate the value, but given how the function is used, and the fact that uint64_t can fit 500,000 years, I don't think this is a real concern.

yamt commented 3 months ago

Thanks, I think this value indeed can overflow, but I'm not sure there's much we can do about it - we could potentially saturate the value, but given how the function is used, and the fact that uint64_t can fit 500,000 years, I don't think this is a real concern.

it's a real concern. consider that a user specified a very long timeout and it actually times out almost immediately because of the overflow.

g0djan commented 3 months ago

I guess the value can be checked for overflowing. If it does overflow then u64::max can be returned and a warning showed.