[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 22/29] device/kmsg.c (kmsgread): check if io_count is larger or e
From: |
Marin Ramesa |
Subject: |
[PATCH 22/29] device/kmsg.c (kmsgread): check if io_count is larger or equal to zero and cast it to vm_size_t |
Date: |
Mon, 9 Dec 2013 23:57:37 +0100 |
Check if member io_count is non-negative. If it is negative the call to
device_read_alloc() will fail. Return KERN_INVALID_ARGUMENT in that case.
* device/kmsg.c (kmsgread): Check if member io_count is non-negative.
(kmsgread) (device_read_alloc) (io_count): Cast to vm_size_t.
---
device/kmsg.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/device/kmsg.c b/device/kmsg.c
index 7034bfc..d2710a3 100644
--- a/device/kmsg.c
+++ b/device/kmsg.c
@@ -96,7 +96,10 @@ kmsgread (dev_t dev, io_req_t ior)
int err;
int amt, len;
- err = device_read_alloc (ior, ior->io_count);
+ if (ior->io_count >= 0)
+ err = device_read_alloc (ior, (vm_size_t)ior->io_count);
+ else
+ return KERN_INVALID_ARGUMENT;
if (err != KERN_SUCCESS)
return err;
--
1.8.1.4
- [PATCH 14/29] device/dev_pager.c (device_pager_data_request): cast to (void *) instead to (char *), (continued)
- [PATCH 14/29] device/dev_pager.c (device_pager_data_request): cast to (void *) instead to (char *), Marin Ramesa, 2013/12/09
- [PATCH 15/29] device/dev_pager.c (device_pager_data_request_done): check if io_count is larger or equal to zero and cast it to vm_size_t, Marin Ramesa, 2013/12/09
- [PATCH 16/29] device/dev_pager.c (device_pager_data_request_done): check if io_residual is larger or equal to zero and cast it to size_t, Marin Ramesa, 2013/12/09
- [PATCH 17/29] device/dev_pager.c (device_pager_data_request_done): remove unnecessary cast, Marin Ramesa, 2013/12/09
- [PATCH 18/29] device/dev_pager.c: remove forward declaration, Marin Ramesa, 2013/12/09
- [PATCH 19/29] device/dev_pager.c: remove forward declarations, Marin Ramesa, 2013/12/09
- [PATCH 20/29] device/ds_routines.c: remove forward declaration, Marin Ramesa, 2013/12/09
- [PATCH 21/29] device/ds_routines.c (device_write_get): check if io_count is larger or equal to zero and cast it to size_t, Marin Ramesa, 2013/12/09
- [PATCH 22/29] device/kmsg.c (kmsgread): check if io_count is larger or equal to zero and cast it to vm_size_t,
Marin Ramesa <=
- [PATCH 23/29] device/kmsg.c (kmsgread, kmsg_read_done): cast arguments to memcpy(), Marin Ramesa, 2013/12/09
- [PATCH 24/29] device/kmsg.c (kmsg_read_done): check if amt is negative, Marin Ramesa, 2013/12/09
- [PATCH 25/29] device/net_io.c: remove forward declarations, Marin Ramesa, 2013/12/09
- [PATCH 26/29] device/net_io.c (net_getstat): check if addr_byte_count is negative, Marin Ramesa, 2013/12/09
- [PATCH 27/29] device/net_io.c (net_getstat): cast arguments to memcpy(), Marin Ramesa, 2013/12/09
- [PATCH 28/29] device/net_io.c (net_getstat): cast arguments to memset(), Marin Ramesa, 2013/12/09
- [PATCH 29/29] device/subrs.c: use io_req_t instead of struct buf, Marin Ramesa, 2013/12/09