Narrowing conversion
Narrowing conversion
Posted Jul 22, 2021 0:08 UTC (Thu) by roc (subscriber, #30627)In reply to: Narrowing conversion by tialaramex
Parent article: The Sequoia seq_file vulnerability
Posted Jul 22, 2021 0:41 UTC (Thu)
by Gaelan (guest, #145108)
[Link] (5 responses)
Posted Jul 22, 2021 1:21 UTC (Thu)
by roc (subscriber, #30627)
[Link] (3 responses)
I'm not sure what the best way to proceed from here is. One option would be to introduce that trait+method for truncating conversions, and deprecate or ban lossy "as" scalar conversions in a future edition. But obviously a lot of existing code would be affected.
Posted Jul 23, 2021 0:47 UTC (Fri)
by khim (subscriber, #9252)
[Link] (2 responses)
Isn't it something Rust editions are supposed to cover?
Posted Jul 23, 2021 7:50 UTC (Fri)
by Fowl (subscriber, #65667)
[Link] (1 responses)
Posted Jul 23, 2021 9:54 UTC (Fri)
by khim (subscriber, #9252)
[Link]
Not really. In Rust, unlike in C++, editions are supposed to coexist. You can write one crate in Rust 2015, another in Rust 2018, and third in Rust 2021. Sure, if you are actively developing your code then you would probably want to upgrade it, but there are no pressure to do that ASAP.
Posted Jul 23, 2021 16:40 UTC (Fri)
by jezuch (subscriber, #52988)
[Link]
FWIW, AFAICT Rust doesn't have implicit *widening* conversion either. Turns out, it too often turns into a footgun.
Posted Jul 22, 2021 8:30 UTC (Thu)
by Wol (subscriber, #4433)
[Link] (2 responses)
If it is (clearly) changing the length of the storage field - as in between int32 and int64, why not? Only an extreme novice would think that you could stuff an int64 into an int32 and not run at least the risk of truncation. Okay if it's not obvious the target is an int32 then it's a more fuzzy issue.
Cheers,
Posted Jul 22, 2021 9:53 UTC (Thu)
by atnot (subscriber, #124910)
[Link]
Posted Jul 22, 2021 11:56 UTC (Thu)
by roc (subscriber, #30627)
[Link]
Narrowing conversion
Narrowing conversion
> But obviously a lot of existing code would be affected.
Narrowing conversion
Narrowing conversion
Narrowing conversion
Narrowing conversion
Narrowing conversion
Wol
Narrowing conversion
Narrowing conversion