aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/utils/libservice/src
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2016-05-19 02:25:09 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2016-05-19 02:25:09 +0300
commitee39338225ed30e47bf066f29d239f0aa09efa8c (patch)
treeb212d9b51f17a55ad812fea7d3727586c90a2003 /utils/libservice/src
parentrename the project (diff)
downloadwindows7-drivers-ee39338225ed30e47bf066f29d239f0aa09efa8c.tar.gz
windows7-drivers-ee39338225ed30e47bf066f29d239f0aa09efa8c.zip
libservice: fix compiler warnings
Diffstat (limited to 'utils/libservice/src')
-rw-r--r--utils/libservice/src/device.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/utils/libservice/src/device.cpp b/utils/libservice/src/device.cpp
index 4ae25a5..825c2bc 100644
--- a/utils/libservice/src/device.cpp
+++ b/utils/libservice/src/device.cpp
@@ -12,6 +12,8 @@
#include <cstddef>
+#include <limits>
+#include <stdexcept>
#include <string>
#include <system_error>
#include <utility>
@@ -54,11 +56,14 @@ namespace libservice
{
DWORD nbreq;
+ if (in_buf_size > std::numeric_limits<DWORD>::max())
+ throw std::range_error("input buffer size is too large");
+
std::size_t nbwritten = DeviceIoControl(
handle,
code,
const_cast<void*>(in_buf),
- in_buf_size,
+ static_cast<DWORD>(in_buf_size),
NULL,
0,
&nbreq,
@@ -91,13 +96,18 @@ namespace libservice
{
DWORD nbreq;
+ if (in_buf_size > std::numeric_limits<DWORD>::max())
+ throw std::range_error("input buffer size is too large");
+ if (out_buf_size > std::numeric_limits<DWORD>::max())
+ throw std::range_error("output buffer size is too large");
+
std::size_t nbwritten = DeviceIoControl(
handle,
code,
const_cast<void*>(in_buf),
- in_buf_size,
+ static_cast<DWORD>(in_buf_size),
out_buf,
- out_buf_size,
+ static_cast<DWORD>(out_buf_size),
&nbreq,
NULL);