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:
Ulrich Czekalla 2000-02-25 21:38:17 +00:00 committed by Alexandre Julliard
parent 6fdfd53eaa
commit 6a80c8a260
1 changed files with 10 additions and 0 deletions

View File

@ -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);