[libbluray-devel] Prevent possible buffer overrun and check the return value of MultiByteToWideChar ()

ace20022 git at videolan.org
Tue Nov 17 08:43:25 CET 2015


libbluray | branch: master | ace20022 <ace20022 at ymail.com> | Thu Nov 12 12:32:43 2015 +0100| [ef147028873a73aa45038e28261d3e379ce06212] | committer: hpi1

Prevent possible buffer overrun and check the return value of MultiByteToWideChar()

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

 src/libbluray/bdj/native/java_awt_BDFontMetrics.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/libbluray/bdj/native/java_awt_BDFontMetrics.c b/src/libbluray/bdj/native/java_awt_BDFontMetrics.c
index 3bbd3c3..f84a382 100644
--- a/src/libbluray/bdj/native/java_awt_BDFontMetrics.c
+++ b/src/libbluray/bdj/native/java_awt_BDFontMetrics.c
@@ -135,7 +135,10 @@ static char *_win32_resolve_font(const char *family, int style)
 
     memset(&lf, 0, sizeof(lf));
     lf.lfCharSet = DEFAULT_CHARSET;
-    MultiByteToWideChar(CP_UTF8, 0, family, -1, lf.lfFaceName, sizeof(lf.lfFaceName));
+    int length = MultiByteToWideChar(CP_UTF8, 0, family, -1, lf.lfFaceName, LF_FACESIZE);
+    if (!length) {
+        return NULL;
+    }
 
     hDC = GetDC(NULL);
     EnumFontFamiliesExW(hDC, &lf, (FONTENUMPROCW)&EnumFontCallbackW, (LPARAM)&data, 0);



More information about the libbluray-devel mailing list