Huw Davies : user32: Pad lfFaceName so we don' t write uninitialised data to the registry.

Alexandre Julliard julliard at winehq.org
Fri Dec 4 09:11:31 CST 2009


Module: wine
Branch: master
Commit: 6fc823430043b559dc014deace6e1472a2b80d92
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=6fc823430043b559dc014deace6e1472a2b80d92

Author: Huw Davies <huw at codeweavers.com>
Date:   Fri Dec  4 14:28:04 2009 +0000

user32: Pad lfFaceName so we don't write uninitialised data to the registry.

Found by Valgrind.

---

 dlls/user32/sysparams.c |   16 +++++++++++++---
 1 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/dlls/user32/sysparams.c b/dlls/user32/sysparams.c
index 4092221..5113acb 100644
--- a/dlls/user32/sysparams.c
+++ b/dlls/user32/sysparams.c
@@ -699,10 +699,20 @@ static BOOL SYSPARAMS_Save( LPCWSTR lpRegKey, LPCWSTR lpValName, LPCWSTR lpValue
 
 /* Convenience function to save logical fonts */
 static BOOL SYSPARAMS_SaveLogFont( LPCWSTR lpRegKey, LPCWSTR lpValName,
-                                    LPLOGFONTW plf, UINT fWinIni )
+                                   const LPLOGFONTW plf, UINT fWinIni )
 {
-    return SYSPARAMS_SaveRaw( lpRegKey, lpValName, (const BYTE*)plf, 
-        sizeof( LOGFONTW), REG_BINARY, fWinIni );
+    LOGFONTW lf = *plf;
+    int len;
+
+    /* Zero pad the end of lfFaceName so we don't write uninitialised
+       data to the registry */
+    lf.lfFaceName[LF_FACESIZE-1] = 0;
+    len = strlenW(lf.lfFaceName);
+    if(len < LF_FACESIZE-1)
+        memset(lf.lfFaceName + len, 0, (LF_FACESIZE - 1 - len) * sizeof(WCHAR));
+
+    return SYSPARAMS_SaveRaw( lpRegKey, lpValName, (const BYTE*)&lf,
+                              sizeof(LOGFONTW), REG_BINARY, fWinIni );
 }
 
 




More information about the wine-cvs mailing list