Commit 6a80c8a2 authored by Ulrich Czekalla's avatar Ulrich Czekalla Committed by Alexandre Julliard

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.
parent 6fdfd53e
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment