[SHELL32] CPrinterFolder: Validate string pointers properly. (#4486)

CORE-18174

Check string pointers before determining the length of strings.
This commit is contained in:
Raymond Czerny 2022-05-05 16:24:38 +02:00 committed by GitHub
parent 056bb94edc
commit e0b9d6d9cd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -102,10 +102,13 @@ static LPITEMIDLIST _ILCreatePrinterItem(PRINTER_INFO_4W *pi)
PIDLPrinterStruct * p;
int size0 = (char*)&tmp.u.cprinter.szName - (char*)&tmp.u.cprinter;
int size = size0;
SIZE_T cchPrinterName, cchServerName;
SIZE_T cchPrinterName = 0;
SIZE_T cchServerName = 0;
cchPrinterName = wcslen(pi->pPrinterName);
cchServerName = wcslen(pi->pServerName);
if (pi->pPrinterName)
cchPrinterName = wcslen(pi->pPrinterName);
if (pi->pServerName)
cchServerName = wcslen(pi->pServerName);
if ((cchPrinterName + cchServerName) > (MAXUSHORT - 2))
{
return NULL;