From ee4a518ae123a03f050120bec120a1f07964453f Mon Sep 17 00:00:00 2001 From: Wohlstand Date: Thu, 24 Mar 2016 12:31:56 +0300 Subject: [PATCH] Tiny fix Forgot to add overflow protection into _lua_freopen function too --- src/lj_fopen.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/lj_fopen.c b/src/lj_fopen.c index 8ad4e922..4906a996 100644 --- a/src/lj_fopen.c +++ b/src/lj_fopen.c @@ -32,8 +32,10 @@ FILE *_lua_freopen(const char *filename, const char *mode, FILE * oldfile) wchar_t path[MAX_PATH]; wchar_t wmode[MAX_PATH]; int new_Len1 = MultiByteToWideChar(CP_UTF8, 0, filename, fn_len_s, path, fn_len_s); + if(new_Len1>=MAX_PATH) return NULL; path[new_Len1] = L'\0'; int new_Len2 = MultiByteToWideChar(CP_UTF8, 0, mode, m_len_s, wmode, m_len_s); + if(new_Len2>=MAX_PATH) return NULL; wmode[new_Len2] = L'\0'; FILE *f = _wfreopen(path, wmode, oldfile); LocalFree(path);