Skip to content

Commit 54d1325

Browse files
authored
Merge pull request #136 from JJL772/fix-u32-overflow
diod: Fix uint32 overflow when Tread/Twrite count > UINT32_MAX-IOHDRSZ
2 parents a140080 + b91d74b commit 54d1325

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/libnpfs/fcall.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ np_read(Npreq *req, Npfcall *tc)
413413
np_logerr (conn->srv, "read: invalid fid");
414414
goto done;
415415
}
416-
if (tc->u.tread.count + IOHDRSZ > conn->msize) {
416+
if ((u64)(tc->u.tread.count) + IOHDRSZ > conn->msize) {
417417
np_uerror(EIO);
418418
np_logerr (conn->srv, "read: count %u too large",
419419
tc->u.tread.count);
@@ -484,7 +484,7 @@ np_write(Npreq *req, Npfcall *tc)
484484
np_uerror(EROFS);
485485
goto done;
486486
}
487-
if (tc->u.twrite.count + IOHDRSZ > conn->msize) {
487+
if ((u64)(tc->u.twrite.count) + IOHDRSZ > conn->msize) {
488488
np_uerror(EIO);
489489
np_logerr (conn->srv, "write: count %u too large",
490490
tc->u.twrite.count);

0 commit comments

Comments
 (0)