assign{Ips,Macs}: Fix integer overflow#1
assign{Ips,Macs}: Fix integer overflow#1GeoffreyFrogeye wants to merge 1 commit intooddlama:mainfrom
Conversation
Half of SHA256 sums truncated to 16 chars actually go over 2^63, which is beyond the range for hexToDec. This fixes the integer overflow error in Lix 2.91+ and Nix 2.25+, as well as undefined behaviour for versions below
|
Hey. Thanks a lot. I also ran into this problem a few weeks ago, when trying to switch to lix. While your solution does fix the problem for this project, as far as I know, it is only solving the one case where it's most likely to happen, and not the underlying problem. One can still call the function exposed by this library and encounter the overflow. I think the best solution would be to get nix/lix to implement either the standard shift operators, or at least some kind of unsafe mul. I have a lix fork that I am using currently, which implements these over at https://forge.lel.lol/patrick/lix/, I just haven't had the time to make a pull requests upstream. You can check out the |
|
Right, I realize now this fix only works for Really cool that you have a proper solution already in the works. Even with adding a feature to Lix it saves code overall. Makes the Feel free to close this PR, unless you think this could still be used as a stopgap. |
Damn, I exclusively use IPv6 :( |
|
Relevant: NixOS/nix#13001 |
|
Also relevant: https://gerrit.lix.systems/c/lix/+/2975 . Glad you're using the same function names :) |
|
I've implemented a shift operation that should work with current nix here: ddc2349. I think we'll use that for the time being until we know what's the status with the new builtins. |
Half of SHA256 sums truncated to 16 chars actually go over 2^63, which is beyond the range for hexToDec.
This fixes the integer overflow error in Lix 2.91+ and Nix 2.25+, as well as undefined behaviour for versions below