mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2024-12-25 02:49:32 +03:00
Lua: Fix bad bitshift in lua_strx2number()
The port of lua to OpenZFS modified lua to use int64_t for numbers instead of double. As part of this, a function for calculating exponentiation was replaced with a bit shift. Unfortunately, it did not handle negative values. Also, it only supported exponents numbers with 7 digits before before overflow. This supports exponents up to 15 digits before overflow. Clang's static analyzer reported this as "Result of operation is garbage or undefined" because the exponent was negative. Reviewed-by: Damian Szuberski <szuberskidamian@gmail.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu> Closes #14204
This commit is contained in:
parent
d6df4441c0
commit
587a39b729
@ -143,7 +143,7 @@ static lua_Number lua_strx2number (const char *s, char **endptr) {
|
||||
*endptr = cast(char *, s); /* valid up to here */
|
||||
ret:
|
||||
if (neg) r = -r;
|
||||
return (r * (1 << e));
|
||||
return ((e >= 0) ? (r * (1ULL << e)) : (r / (1ULL << -e)));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user