From: Gerald Pfeifer Subject: propsys: Use snprintf in PROPVAR_ConvertFILETIME. Message-Id: Date: Sat, 11 Feb 2017 23:13:00 +0100 (CET) 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 --- 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