From ee39338225ed30e47bf066f29d239f0aa09efa8c Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Thu, 19 May 2016 02:25:09 +0300 Subject: libservice: fix compiler warnings --- utils/libservice/src/device.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'utils/libservice/src/device.cpp') 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 +#include +#include #include #include #include @@ -54,11 +56,14 @@ namespace libservice { DWORD nbreq; + if (in_buf_size > std::numeric_limits::max()) + throw std::range_error("input buffer size is too large"); + std::size_t nbwritten = DeviceIoControl( handle, code, const_cast(in_buf), - in_buf_size, + static_cast(in_buf_size), NULL, 0, &nbreq, @@ -91,13 +96,18 @@ namespace libservice { DWORD nbreq; + if (in_buf_size > std::numeric_limits::max()) + throw std::range_error("input buffer size is too large"); + if (out_buf_size > std::numeric_limits::max()) + throw std::range_error("output buffer size is too large"); + std::size_t nbwritten = DeviceIoControl( handle, code, const_cast(in_buf), - in_buf_size, + static_cast(in_buf_size), out_buf, - out_buf_size, + static_cast(out_buf_size), &nbreq, NULL); -- cgit v1.2.3