Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mumble-voip/mumble.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikkel Krautz <mikkel@krautz.dk>2015-11-25 00:53:42 +0300
committerMikkel Krautz <mikkel@krautz.dk>2015-11-25 00:53:42 +0300
commita3e7958f1605339560679cbbd3a27de4fd12066c (patch)
tree33b04c8d84dd49f7889e654c4161ac19b135ae73 /overlay
parent5f79a3e4e97c926188c37f2b8371fb5d3c5b6b16 (diff)
overlay: add runtime check for when GetFnOffsetInModule()'s return value would have overflowed its return type.
See also mumble-voip/mumble#1924
Diffstat (limited to 'overlay')
-rw-r--r--overlay/lib.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/overlay/lib.cpp b/overlay/lib.cpp
index 537edb027..98ff61cc4 100644
--- a/overlay/lib.cpp
+++ b/overlay/lib.cpp
@@ -33,6 +33,8 @@
#include "overlay_blacklist.h"
#include "overlay_exe/overlay_exe.h"
+#undef max // for std::numeric_limits<T>::max()
+
static HANDLE hMapObject = NULL;
static HANDLE hHookMutex = NULL;
static HHOOK hhookWnd = 0;
@@ -817,5 +819,14 @@ int GetFnOffsetInModule(voidFunc fnptr, wchar_t *refmodulepath, unsigned int ref
unsigned char *fn = reinterpret_cast<unsigned char *>(fnptr);
unsigned char *base = reinterpret_cast<unsigned char *>(hModule);
- return fn - base;
+ unsigned long off = static_cast<unsigned long>(fn - base);
+
+ // XXX: convert this function to use something other than int.
+ // Issue mumble-voip/mumble#1924.
+ if (off > static_cast<unsigned long>(std::numeric_limits<int>::max())) {
+ ods("Internal overlay error: GetFnOffsetInModule() offset greater than return type can hold.");
+ return -1;
+ }
+
+ return static_cast<int>(off);
}