diff options
author | reimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2006-11-29 12:44:05 +0000 |
---|---|---|
committer | reimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2006-11-29 12:44:05 +0000 |
commit | 8f874369b5da96d557a1cc25b8c9cf3627844371 (patch) | |
tree | 90df8835fccbc90cd703f162738654532e35fee8 | |
parent | 383008da883f8a2190f7ab49f5ee45c334a54d86 (diff) | |
download | mpv-8f874369b5da96d557a1cc25b8c9cf3627844371.tar.bz2 mpv-8f874369b5da96d557a1cc25b8c9cf3627844371.tar.xz |
Some extra checks and safety space for add_stub function.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@21382 b3059339-0415-0410-9bf9-f77b7e298cf2
-rw-r--r-- | loader/win32.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/loader/win32.c b/loader/win32.c index acdf576082..3a02eef2a6 100644 --- a/loader/win32.c +++ b/loader/win32.c @@ -5278,16 +5278,22 @@ static void ext_stubs(void) //static void add_stub(int pos) +#define MAX_STUB_SIZE 0x60 +#define MAX_NUM_STUBS 200 static int pos=0; -static char extcode[20000];// place for 200 unresolved exports +static char extcode[MAX_NUM_STUBS * MAX_STUB_SIZE]; static void* add_stub(void) { int i; // generated code in runtime! - char* answ = (char*)extcode+pos*0x30; - memcpy(answ, ext_stubs, 0x2f); // 0x2c is current size - for (i = 0; i < 0x30 - 3; i++) { + char* answ = extcode + pos * MAX_STUB_SIZE; + if (pos >= MAX_NUM_STUBS) { + printf("too many stubs, expect crash\n"); + return NULL; + } + memcpy(answ, ext_stubs, MAX_STUB_SIZE); + for (i = 0; i < MAX_STUB_SIZE - 3; i++) { if (*(int*)(answ + i) == 0xdeadabcd) break; } |