Module: wine Branch: refs/heads/master Commit: 7afe18ec27d4f9ba31b2130c0529b5d7678f0549 URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=7afe18ec27d4f9ba31b2130c...
Author: Huw Davies huw@codeweavers.com Date: Thu Jun 15 11:36:00 2006 +0100
printing: Don't limit the printer name length to CCHDEVICENAME characters.
---
dlls/wineps.drv/init.c | 12 ++++++++++-- dlls/winspool.drv/info.c | 21 +++++++-------------- 2 files changed, 17 insertions(+), 16 deletions(-)
diff --git a/dlls/wineps.drv/init.c b/dlls/wineps.drv/init.c index ca749af..f50d4f5 100644 --- a/dlls/wineps.drv/init.c +++ b/dlls/wineps.drv/init.c @@ -302,7 +302,7 @@ BOOL PSDRV_CreateDC( HDC hdc, PSDRV_PDEV { 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_PDEV 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);
diff --git a/dlls/winspool.drv/info.c b/dlls/winspool.drv/info.c index dc8bd79..9d6e1c0 100644 --- a/dlls/winspool.drv/info.c +++ b/dlls/winspool.drv/info.c @@ -2032,13 +2032,6 @@ HANDLE WINAPI AddPrinterW(LPWSTR pName, 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; @@ -2109,19 +2102,19 @@ HANDLE WINAPI AddPrinterW(LPWSTR pName, dmW = pi->pDevMode; else { - dmW = HeapAlloc(GetProcessHeap(), 0, size); + dmW = HeapAlloc(GetProcessHeap(), 0, size); ZeroMemory(dmW,size); - dmW->dmSize = size; - if (0>DocumentPropertiesW(0,0,pi->pPrinterName,dmW,NULL,DM_OUT_BUFFER)) + dmW->dmSize = size; + if (0>DocumentPropertiesW(0,0,pi->pPrinterName,dmW,NULL,DM_OUT_BUFFER)) { - WARN("DocumentPropertiesW on printer '%s' failed!\n", debugstr_w(pi->pPrinterName)); + WARN("DocumentPropertiesW on printer '%s' failed!\n", debugstr_w(pi->pPrinterName)); HeapFree(GetProcessHeap(),0,dmW); dmW=NULL; - } + } else { - /* set devmode to printer name */ - strcpyW(dmW->dmDeviceName,pi->pPrinterName); + /* set devmode to printer name */ + lstrcpynW(dmW->dmDeviceName, pi->pPrinterName, CCHDEVICENAME); } }