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:
Warner Losh 2024-03-11 14:15:10 -06:00
parent 3ae18fdfbc
commit 8b1925f29c

View File

@ -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);