Commit 7afe18ec authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

printing: Don't limit the printer name length to CCHDEVICENAME characters.

parent 36bf71c1
......@@ -302,7 +302,7 @@ BOOL PSDRV_CreateDC( HDC hdc, PSDRV_PDEVICE **pdev, LPCWSTR driver, LPCWSTR devi
{
PSDRV_PDEVICE *physDev;
PRINTERINFO *pi;
char deviceA[CCHDEVICENAME];
char *deviceA;
/* If no device name was specified, retrieve the device name
* from the DEVMODE structure from the DC's physDev.
......@@ -310,12 +310,20 @@ BOOL PSDRV_CreateDC( HDC hdc, PSDRV_PDEVICE **pdev, LPCWSTR driver, LPCWSTR devi
if ( !device && *pdev )
{
physDev = *pdev;
deviceA = HeapAlloc(GetProcessHeap(), 0, CCHDEVICENAME);
lstrcpynA(deviceA, (LPCSTR)physDev->Devmode->dmPublic.dmDeviceName, CCHDEVICENAME);
}
else
WideCharToMultiByte(CP_ACP, 0, device, -1, deviceA, sizeof(deviceA), NULL, NULL);
{
DWORD len = WideCharToMultiByte(CP_ACP, 0, device, -1, NULL, 0, NULL, NULL);
deviceA = HeapAlloc(GetProcessHeap(), 0, len);
WideCharToMultiByte(CP_ACP, 0, device, -1, deviceA, len, NULL, NULL);
}
pi = PSDRV_FindPrinterInfo(deviceA);
HeapFree(GetProcessHeap(), 0, deviceA);
deviceA = NULL;
TRACE("(%s %s %s %p)\n", debugstr_w(driver), debugstr_w(device),
debugstr_w(output), initData);
......
......@@ -2032,13 +2032,6 @@ HANDLE WINAPI AddPrinterW(LPWSTR pName, DWORD Level, LPBYTE pPrinter)
SetLastError(ERROR_INVALID_LEVEL);
return 0;
}
if (strlenW(pi->pPrinterName) >= CCHDEVICENAME) {
ERR("Printername %s must not exceed length of DEVMODE.dmDeviceName !\n",
debugstr_w(pi->pPrinterName)
);
SetLastError(ERROR_INVALID_LEVEL);
return 0;
}
if(!pPrinter) {
SetLastError(ERROR_INVALID_PARAMETER);
return 0;
......@@ -2121,7 +2114,7 @@ HANDLE WINAPI AddPrinterW(LPWSTR pName, DWORD Level, LPBYTE pPrinter)
else
{
/* set devmode to printer name */
strcpyW(dmW->dmDeviceName,pi->pPrinterName);
lstrcpynW(dmW->dmDeviceName, pi->pPrinterName, CCHDEVICENAME);
}
}
......
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