wineps: don't overflow WriteSpool

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



        Huw Davies <huw@xxxxxxxxxxxxxxx>
        Let PSDRV_WriteSpool cope with strings longer than 0xffff bytes.
-- 
Huw Davies
huw@xxxxxxxxxxxxxxx
Index: dlls/wineps/ps.c
===================================================================
RCS file: /home/wine/wine/dlls/wineps/ps.c,v
retrieving revision 1.21
diff -u -r1.21 ps.c
--- dlls/wineps/ps.c	11 Nov 2003 20:41:14 -0000	1.21
+++ dlls/wineps/ps.c	4 Dec 2003 16:35:27 -0000
@@ -193,8 +193,10 @@
 "/%s %d array def\n";
 
 
-int PSDRV_WriteSpool(PSDRV_PDEVICE *physDev, LPCSTR lpData, WORD cch)
+DWORD PSDRV_WriteSpool(PSDRV_PDEVICE *physDev, LPCSTR lpData, DWORD cch)
 {
+    int num, num_left = cch;
+
     if(physDev->job.quiet) {
         TRACE("ignoring output\n");
 	return 0;
@@ -204,7 +206,16 @@
         if( !PSDRV_StartPage(physDev) )
 	    return 0;
     }
-    return WriteSpool16( physDev->job.hJob, (LPSTR)lpData, cch );
+
+    do {
+        num = min(num_left, 0x8000);
+        if(WriteSpool16( physDev->job.hJob, (LPSTR)lpData, num ) != num)
+            return 0;
+        lpData += num;
+        num_left -= num;
+    } while(num_left);
+
+    return cch;
 }
 
 
Index: dlls/wineps/psdrv.h
===================================================================
RCS file: /home/wine/wine/dlls/wineps/psdrv.h,v
retrieving revision 1.45
diff -u -r1.45 psdrv.h
--- dlls/wineps/psdrv.h	12 Nov 2003 22:42:55 -0000	1.45
+++ dlls/wineps/psdrv.h	4 Dec 2003 16:35:27 -0000
@@ -450,7 +450,7 @@
 extern BOOL PSDRV_WriteDIBits16(PSDRV_PDEVICE *physDev, const WORD *words, int number);
 extern BOOL PSDRV_WriteDIBits24(PSDRV_PDEVICE *physDev, const BYTE *bits, int number);
 extern BOOL PSDRV_WriteDIBits32(PSDRV_PDEVICE *physDev, const BYTE *bits, int number);
-extern int PSDRV_WriteSpool(PSDRV_PDEVICE *physDev, LPCSTR lpData, WORD cch);
+extern DWORD PSDRV_WriteSpool(PSDRV_PDEVICE *physDev, LPCSTR lpData, DWORD cch);
 extern BOOL PSDRV_WritePatternDict(PSDRV_PDEVICE *physDev, BITMAP *bm, BYTE *bits);
 extern BOOL PSDRV_WriteDIBPatternDict(PSDRV_PDEVICE *physDev, BITMAPINFO *bmi, UINT usage);
 extern BOOL PSDRV_WriteArrayPut(PSDRV_PDEVICE *physDev, CHAR *pszArrayName, INT nIndex, LONG lCoord);


[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux