[PATCH] gdi32: do not overwrite variables (Coverity)
Marcus Meissner
marcus at jet.franken.de
Thu May 9 03:15:02 CDT 2013
Hi,
CID 743138,743137,743136
wrote a DWORD (32bit) into a SHORT (16bit) entity.
Ciao, Marcus
---
dlls/gdi32/freetype.c | 21 ++++++++++++++++++---
1 file changed, 18 insertions(+), 3 deletions(-)
diff --git a/dlls/gdi32/freetype.c b/dlls/gdi32/freetype.c
index 141238b..2aa5b72 100644
--- a/dlls/gdi32/freetype.c
+++ b/dlls/gdi32/freetype.c
@@ -1373,6 +1373,21 @@ static LONG reg_load_dword(HKEY hkey, const WCHAR *value, DWORD *data)
return ERROR_SUCCESS;
}
+static LONG reg_load_short(HKEY hkey, const WCHAR *value, SHORT *data)
+{
+ DWORD type, size = sizeof(DWORD);
+ DWORD dw;
+
+ if (RegQueryValueExW(hkey, value, NULL, &type, (BYTE *)&dw, &size) ||
+ type != REG_DWORD || size != sizeof(DWORD))
+ {
+ *data = 0;
+ return ERROR_BAD_CONFIGURATION;
+ }
+ *data = dw;
+ return ERROR_SUCCESS;
+}
+
static inline LONG reg_save_dword(HKEY hkey, const WCHAR *value, DWORD data)
{
return RegSetValueExW(hkey, value, 0, REG_DWORD, (BYTE*)&data, sizeof(DWORD));
@@ -1411,7 +1426,7 @@ static void load_face(HKEY hkey_face, WCHAR *face_name, Family *family, void *bu
needed = sizeof(face->fs);
RegQueryValueExW(hkey_face, face_font_sig_value, NULL, NULL, (BYTE*)&face->fs, &needed);
- if(reg_load_dword(hkey_face, face_height_value, (DWORD*)&face->size.height) != ERROR_SUCCESS)
+ if(reg_load_short(hkey_face, face_height_value, &face->size.height) != ERROR_SUCCESS)
{
face->scalable = TRUE;
memset(&face->size, 0, sizeof(face->size));
@@ -1419,11 +1434,11 @@ static void load_face(HKEY hkey_face, WCHAR *face_name, Family *family, void *bu
else
{
face->scalable = FALSE;
- reg_load_dword(hkey_face, face_width_value, (DWORD*)&face->size.width);
+ reg_load_short(hkey_face, face_width_value, &face->size.width);
reg_load_dword(hkey_face, face_size_value, (DWORD*)&face->size.size);
reg_load_dword(hkey_face, face_x_ppem_value, (DWORD*)&face->size.x_ppem);
reg_load_dword(hkey_face, face_y_ppem_value, (DWORD*)&face->size.y_ppem);
- reg_load_dword(hkey_face, face_internal_leading_value, (DWORD*)&face->size.internal_leading);
+ reg_load_short(hkey_face, face_internal_leading_value, &face->size.internal_leading);
TRACE("Adding bitmap size h %d w %d size %ld x_ppem %ld y_ppem %ld\n",
face->size.height, face->size.width, face->size.size >> 6,
--
1.7.10.4
More information about the wine-patches
mailing list