[PATCH] [WinHelp]: fix for 5314

Eric Pouech eric.pouech at orange.fr
Sat Sep 20 14:47:51 CDT 2008


in some bogus help files, the font string is obviously wrong
protect the RTF generated stream against this

A+
---

 programs/winhlp32/hlpfile.c |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)


diff --git a/programs/winhlp32/hlpfile.c b/programs/winhlp32/hlpfile.c
index 99043ac..ae14c80 100644
--- a/programs/winhlp32/hlpfile.c
+++ b/programs/winhlp32/hlpfile.c
@@ -23,6 +23,7 @@
 #include <stdarg.h>
 #include <stdio.h>
 #include <string.h>
+#include <ctype.h>
 
 #include "windef.h"
 #include "winbase.h"
@@ -1733,8 +1734,16 @@ static BOOL HLPFILE_ReadFont(HLPFILE* hlpfile)
 
         if (idx < face_num)
         {
-            memcpy(hlpfile->fonts[i].LogFont.lfFaceName, ref + face_offset + idx * len, min(len, LF_FACESIZE - 1));
-            hlpfile->fonts[i].LogFont.lfFaceName[min(len, LF_FACESIZE - 1)] = '\0';
+            int k;
+            char ch;
+
+            for (k = 0; k < min(len, LF_FACESIZE - 1); k++)
+            {
+                ch = ((const char*)ref)[face_offset + idx * len + k];
+                if (!ch || !isalpha(ch)) break;
+                hlpfile->fonts[i].LogFont.lfFaceName[k] = ch;
+            }
+            hlpfile->fonts[i].LogFont.lfFaceName[k] = '\0';
         }
         else
         {





More information about the wine-patches mailing list