[libbluray-devel] Add some checks to win32_get_font_dir().

ace20022 git at videolan.org
Tue Nov 17 08:45:31 CET 2015


libbluray | branch: master | ace20022 <ace20022 at ymail.com> | Thu Nov 12 13:07:31 2015 +0100| [36ce17026ea5ca0915e99d2c7def362810f751c6] | committer: hpi1

Add some checks to win32_get_font_dir().

> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=36ce17026ea5ca0915e99d2c7def362810f751c6
---

 src/file/dirs_win32.c |   12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/file/dirs_win32.c b/src/file/dirs_win32.c
index 5279ea5..e165fea 100644
--- a/src/file/dirs_win32.c
+++ b/src/file/dirs_win32.c
@@ -38,8 +38,16 @@ char *win32_get_font_dir(const char *font_file)
 {
     wchar_t wdir[MAX_PATH];
     if (S_OK != SHGetFolderPathW(NULL, CSIDL_FONTS, NULL, SHGFP_TYPE_CURRENT, wdir)) {
-        GetWindowsDirectoryW(wdir, MAX_PATH);
-        wcscat(wdir, L"\\fonts");
+        int lenght = GetWindowsDirectoryW(wdir, MAX_PATH);
+        if (lenght == 0 || lenght > (MAX_PATH - 8)) {
+            BD_DEBUG(DBG_FILE, "Font directory path too long!\n");
+            return NULL;
+        }
+        if (!wcscat(wdir, L"\\fonts")) {
+            BD_DEBUG(DBG_FILE, "Could not construct font directory path!\n");
+            return NULL;
+        }
+
     }
 
     int   len  = WideCharToMultiByte (CP_UTF8, 0, wdir, -1, NULL, 0, NULL, NULL);



More information about the libbluray-devel mailing list