propsys: Use snprintf in PROPVAR_ConvertFILETIME.
Gerald Pfeifer
gerald at pfeifer.com
Sat Feb 11 16:13:00 CST 2017
While working on this patch, in particular identifying the maximum
size for snprintf, I noticed that lstrlenA(format)+1 should be the
same as a plain sizeof.
(This, too, is a little odd in that it actually overestimates the
size of this buffer a little, and I can look into this with a follow
up patch if there is interest.)
Signed-off-by: Gerald Pfeifer <gerald at pfeifer.com>
---
dlls/propsys/propvar.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/dlls/propsys/propvar.c b/dlls/propsys/propvar.c
index 002555e489..dc45c363be 100644
--- a/dlls/propsys/propvar.c
+++ b/dlls/propsys/propvar.c
@@ -50,13 +50,15 @@ static HRESULT PROPVAR_ConvertFILETIME(PROPVARIANT *ppropvarDest,
static const char format[] = "%04d/%02d/%02d:%02d:%02d:%02d.%03d";
ppropvarDest->u.pszVal = HeapAlloc(GetProcessHeap(), 0,
- lstrlenA(format) + 1);
+ sizeof(format));
if (!ppropvarDest->u.pszVal)
return E_OUTOFMEMORY;
- sprintf(ppropvarDest->u.pszVal, format, time.wYear, time.wMonth,
- time.wDay, time.wHour, time.wMinute,
- time.wSecond, time.wMilliseconds);
+ snprintf( ppropvarDest->u.pszVal, sizeof(format),
+ format,
+ time.wYear, time.wMonth, time.wDay,
+ time.wHour, time.wMinute, time.wSecond,
+ time.wMilliseconds );
return S_OK;
}
--
2.11.0
More information about the wine-patches
mailing list