This patch initializes the return buffer used in GetPrinterDriverA to
zeros. This prevents buffer overruns caused by accessing garbage data. Some improvements to the NULL check patch. Gautam Jain EnumPrinters is not returning the number of printers found in case the parameter dwLevel is 1.
This commit is contained in:
parent
6fdfd53eaa
commit
6a80c8a260
|
@ -206,6 +206,12 @@ BOOL WINAPI OpenPrinterA(LPSTR lpPrinterName,HANDLE *phPrinter,
|
|||
LPOPENEDPRINTERA lpOpenedPrinter;
|
||||
HKEY hkeyPrinters, hkeyPrinter;
|
||||
|
||||
if (!lpPrinterName) {
|
||||
WARN("(printerName: NULL, pDefault %p Ret: False\n", pDefault);
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
TRACE("(printerName: %s, pDefault %p\n", lpPrinterName, pDefault);
|
||||
|
||||
/* Check Printer exists */
|
||||
|
@ -1045,6 +1051,8 @@ BOOL WINAPI EnumPrintersA(
|
|||
switch(dwLevel) {
|
||||
case 1:
|
||||
RegCloseKey(hkeyPrinters);
|
||||
if (lpdwReturned)
|
||||
*lpdwReturned = number;
|
||||
return TRUE;
|
||||
|
||||
case 2:
|
||||
|
@ -1161,6 +1169,8 @@ BOOL WINAPI GetPrinterDriverA(HANDLE hPrinter, LPSTR pEnvironment,
|
|||
TRACE("(%d,%s,%ld,%p,%ld,%p)\n",hPrinter,pEnvironment,
|
||||
Level,pDriverInfo,cbBuf, pcbNeeded);
|
||||
|
||||
ZeroMemory(pDriverInfo, cbBuf);
|
||||
|
||||
lpOpenedPrinter = WINSPOOL_GetOpenedPrinterA(hPrinter);
|
||||
if(!lpOpenedPrinter) {
|
||||
SetLastError(ERROR_INVALID_HANDLE);
|
||||
|
|
Loading…
Reference in New Issue