wasm-micro-runtime icon indicating copy to clipboard operation
wasm-micro-runtime copied to clipboard

This value might overflow 64 bit int

Open g0djan opened this issue 1 year ago • 3 comments

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

g0djan avatar Jul 10 '24 13:07 g0djan

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.

loganek avatar Jul 10 '24 15:07 loganek

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.

yamt avatar Jul 17 '24 02:07 yamt

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

g0djan avatar Jul 17 '24 13:07 g0djan