return FALSE;
}
+static VOID
+IntUnicodeStringToBuffer(LPWSTR pszBuffer, USHORT cbBuffer, const UNICODE_STRING *pString)
+{
+ USHORT cbLength = pString->Length;
+
+ if (cbBuffer < sizeof(UNICODE_NULL))
+ return;
+
+ if (cbLength > cbBuffer - sizeof(UNICODE_NULL))
+ cbLength = cbBuffer - sizeof(UNICODE_NULL);
+
+ RtlCopyMemory(pszBuffer, pString->Buffer, cbLength);
+ pszBuffer[cbLength / sizeof(WCHAR)] = UNICODE_NULL;
+}
+
static BOOL
SubstituteFontRecurse(LOGFONTW* pLogFont)
{
if (!Found)
break;
- RtlStringCchCopyW(pLogFont->lfFaceName, LF_FACESIZE, OutputNameW.Buffer);
+ IntUnicodeStringToBuffer(pLogFont->lfFaceName, sizeof(pLogFont->lfFaceName), &OutputNameW);
if (CharSetMap[FONTSUBST_FROM] == DEFAULT_CHARSET ||
CharSetMap[FONTSUBST_FROM] == pLogFont->lfCharSet)
EngSetLastError(ERROR_NOT_ENOUGH_MEMORY);
return 0; /* failure */
}
- RtlCopyMemory(FontGDI->Filename, pFileName->Buffer, pFileName->Length);
- FontGDI->Filename[pFileName->Length / sizeof(WCHAR)] = UNICODE_NULL;
+
+ IntUnicodeStringToBuffer(FontGDI->Filename, sizeof(FontGDI->Filename), pFileName);
}
else
{
/* full name */
if (!FullName)
FullName = (WCHAR*)((ULONG_PTR) Otm + (ULONG_PTR)Otm->otmpFaceName);
-
+
RtlStringCbCopyW(Info->EnumLogFontEx.elfFullName,
sizeof(Info->EnumLogFontEx.elfFullName),
FullName);
continue; /* mismatch */
}
- RtlStringCchCopyW(lf.lfFaceName, LF_FACESIZE, pFromW->Buffer);
+ IntUnicodeStringToBuffer(lf.lfFaceName, sizeof(lf.lfFaceName), pFromW);
SubstituteFontRecurse(&lf);
RtlInitUnicodeString(&NameW, lf.lfFaceName);
if (NT_SUCCESS(Status))
{
/* truncated copy */
- Name.Length = (USHORT)min(Name.Length, (LF_FACESIZE - 1) * sizeof(WCHAR));
- RtlStringCbCopyNW(TextObj->TextFace, Name.Length + sizeof(WCHAR), Name.Buffer, Name.Length);
-
+ IntUnicodeStringToBuffer(TextObj->TextFace, sizeof(TextObj->TextFace), &Name);
RtlFreeUnicodeString(&Name);
}
}