Fix the calculations of the length of the unread message buffer
contents. The code was subtracting two unsigned ints, stored the result in a log and expected it to be the same as of a signed subtraction; this does only work on platforms where int and long have the same size (due to overflows). Instead, cast to long before the subtraction; the numbers are guaranteed to be small enough so that there will be no overflows because of that.
This commit is contained in:
parent
72d26fe4c9
commit
5775150869
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=105590
@ -147,7 +147,7 @@ logread(dev_t dev, struct uio *uio, int flag)
|
||||
logsoftc.sc_state &= ~LOG_RDWAIT;
|
||||
|
||||
while (uio->uio_resid > 0) {
|
||||
l = mbp->msg_bufx - mbp->msg_bufr;
|
||||
l = (long)mbp->msg_bufx - mbp->msg_bufr;
|
||||
if (l < 0)
|
||||
l = mbp->msg_size - mbp->msg_bufr;
|
||||
l = min(l, uio->uio_resid);
|
||||
@ -218,7 +218,7 @@ logioctl(dev_t dev, u_long com, caddr_t data, int flag, struct thread *td)
|
||||
/* return number of characters immediately available */
|
||||
case FIONREAD:
|
||||
s = splhigh();
|
||||
l = msgbufp->msg_bufx - msgbufp->msg_bufr;
|
||||
l = (long)msgbufp->msg_bufx - msgbufp->msg_bufr;
|
||||
splx(s);
|
||||
if (l < 0)
|
||||
l += msgbufp->msg_size;
|
||||
|
Loading…
Reference in New Issue
Block a user