-
Notifications
You must be signed in to change notification settings - Fork 473
Closed
Description
When I checked out this crate and used it as a path dependency, cargo warns be about several places with undefined behavior.
To reproduce:
git clone git@github.com:smoltcp-rs/smoltcp.git --branch v0.10.0
In a crate that uses a target with "target-pointer-width": "16"
specify in Cargo.toml
(assuming the directories are next to each other):
[dependency.smoltcp]
path= "../smoltcp"
When building/checking in the crate with the 16 bit target, cargo yields:
error: this arithmetic operation will overflow
--> /home/dweber/gh/smoltcp/src/socket/tcp.rs:489:26
|
489 | if rx_capacity > (1 << 30) {
| ^^^^^^^^^ attempt to shift left by `30_i32`, which would overflow
|
= note: `#[deny(arithmetic_overflow)]` on by default
error: this arithmetic operation will overflow
--> /home/dweber/gh/smoltcp/src/socket/tcp.rs:597:13
|
597 | (1 << 16) - 1,
| ^^^^^^^^^ attempt to shift left by `16_i32`, which would overflow
error: this arithmetic operation will overflow
--> /home/dweber/gh/smoltcp/src/socket/tcp.rs:2158:63
|
2158 | repr.window_len = self.rx_buffer.window().min((1 << 16) - 1) as u16;
| ^^^^^^^^^ attempt to shift left by `16_i32`, which would overflow
Note: if I specify the dependency as usual (smoltcp= "0.10.0"
), these warnings won't appear but the behavior is still undefined.
Metadata
Metadata
Assignees
Labels
No labels