mirror of
https://github.com/freebsd/freebsd-src
synced 2024-07-09 04:36:31 +00:00
kboot: Avoid UB in signed shift
offset is signed. Copy it to the unsigned res before shifting. This avoids any possible undefined behavior for right shifting signed numbers. No functional change intended (and the code generated is the nearly same for aarch64). Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D44285
This commit is contained in:
parent
3ae18fdfbc
commit
8b1925f29c
|
@ -133,8 +133,9 @@ hostfs_seek(struct open_file *f, off_t offset, int whence)
|
|||
* from V7 later ISO-C). Also assumes we have to support powerpc still,
|
||||
* it's interface is weird for legacy reasons....
|
||||
*/
|
||||
offl = offset & 0xffffffff;
|
||||
offh = (offset >> 32) & 0xffffffff;
|
||||
res = (uint64_t)offset;
|
||||
offl = res & 0xfffffffful;
|
||||
offh = (res >> 32) & 0xfffffffful;
|
||||
err = host_llseek(hf->hf_fd, offh, offl, &res, whence);
|
||||
if (err < 0)
|
||||
return (err);
|
||||
|
|
Loading…
Reference in New Issue
Block a user