View | Details | Raw Unified | Return to bug 72382
Collapse All | Expand All

(-)files/patch-ae (-58 / +125 lines)
Lines 1-11 Link Here
1
--- xvimage.c~	Fri Jan 13 18:11:36 1995
1
--- xvimage.c
2
+++ xvimage.c	Tue Oct 15 16:41:47 1996
2
+++ xvimage.c	Wed Jan 12 15:10:24 2000
3
@@ -46,6 +46,274 @@
3
@@ -29,40 +29,302 @@
4
 static void flipSel           PARM((int));
5
 static void do_zoom           PARM((int, int));
6
 static void compute_zoom_rect PARM((int, int, int*, int*, int*, int*));
7
 static void do_unzoom         PARM((void));
8
 static void do_pan            PARM((int, int));
9
 static void do_pan_calc       PARM((int, int, int *, int *));
10
 static void crop1             PARM((int, int, int, int, int));
11
 static int  doAutoCrop24      PARM((void));
12
 static void floydDitherize1   PARM((XImage *, byte *, int, int, int, 
13
 				    byte *, byte *,byte *));
14
 static int  highbit           PARM((unsigned long));
15
 
16
 static int  doPadSolid        PARM((char *, int, int, int, int));
17
 static int  doPadBggen        PARM((char *, int, int, int, int));
18
 static int  doPadLoad         PARM((char *, int, int, int, int));
19
 
20
 static int  doPadPaste        PARM((byte *, int, int, int, int));
4
 static int  ReadImageFile1    PARM((char *, PICINFO *));
21
 static int  ReadImageFile1    PARM((char *, PICINFO *));
5
 
22
 
6
 
23
 
7
+/* The following array represents the pixel values for each shade of
24
+/* The following array represents the pixel values for each shade
8
+ * the primary color components.
25
+ * of the primary color components.
9
+ * If 'p' is a pointer to a source image rgb-byte-triplet, we can
26
+ * If 'p' is a pointer to a source image rgb-byte-triplet, we can
10
+ * construct the output pixel value simply by 'oring' together
27
+ * construct the output pixel value simply by 'oring' together
11
+ * the corresponding components:
28
+ * the corresponding components:
Lines 20-26 Link Here
20
+ * This is both efficient and generic, since the only assumption
37
+ * This is both efficient and generic, since the only assumption
21
+ * is that the primary color components have separate bits.
38
+ * is that the primary color components have separate bits.
22
+ * The order and distribution of bits does not matter, and we
39
+ * The order and distribution of bits does not matter, and we
23
+ * don't need additional vaiables and shifting/masking code.
40
+ * don't need additional variables and shifting/masking code.
24
+ * The array size is 3 KBytes total and thus very reasonable.
41
+ * The array size is 3 KBytes total and thus very reasonable.
25
+ */
42
+ */
26
+
43
+
Lines 42-62 Link Here
42
+ * The method is to draw points in a pixmap with the specified shades
59
+ * The method is to draw points in a pixmap with the specified shades
43
+ * of primary colors and then get the corresponding XImage pixel
60
+ * of primary colors and then get the corresponding XImage pixel
44
+ * representation.
61
+ * representation.
45
+ * Thus we can get away with any Bit-order/Byte-Order dependencies.
62
+ * Thus we can get away with any Bit-order/Byte-order dependencies.
46
+ *
63
+ *
47
+ * The routine uses some global X variables: theDisp, theScreen,
64
+ * The routine uses some global X variables:
48
+ * and dispDEEP. Adapt these to your application as necessary.
65
+ * theDisp, theScreen, dispDEEP, and theCmap.
66
+ * Adapt these to your application as necessary.
49
+ * I've not passed them in as parameters, since for other platforms
67
+ * I've not passed them in as parameters, since for other platforms
50
+ * than X these may be different (see vfixpix.c), and so the
68
+ * than X these may be different (see vfixpix.c), and so the
51
+ * screen_init() interface is unique.
69
+ * screen_init() interface is unique.
52
+ *
53
+ * BUG: I've read in the "Xlib Programming Manual" from O'Reilly &
54
+ * Associates, that the DefaultColormap in TrueColor might not
55
+ * provide the full shade representation in XAllocColor.
56
+ * In this case one had to provide a 'best' colormap instead.
57
+ * However, my tests with Xaccel on a Linux-Box with a Mach64
58
+ * card were fully successful, so I leave that potential problem
59
+ * to you at the moment and would appreciate any suggestions...
60
+ */
70
+ */
61
+
71
+
62
+static void screen_init()
72
+static void screen_init()
Lines 73-115 Link Here
73
+
83
+
74
+  check_map = XCreatePixmap(theDisp, RootWindow(theDisp,theScreen),
84
+  check_map = XCreatePixmap(theDisp, RootWindow(theDisp,theScreen),
75
+			    1, 1, dispDEEP);
85
+			    1, 1, dispDEEP);
76
+  check_gc = XCreateGC(theDisp, RootWindow(theDisp,theScreen), 0, NULL);
86
+  check_gc = XCreateGC(theDisp, check_map, 0, NULL);
77
+  for (ci = 0; ci < 3; ci++) {
87
+  for (ci = 0; ci < 3; ci++) {
78
+    for (i = 0; i < 256; i++) {
88
+    for (i = 0; i < 256; i++) {
79
+      check_col.flags = DoRed | DoGreen | DoBlue;
80
+      check_col.red = 0;
89
+      check_col.red = 0;
81
+      check_col.green = 0;
90
+      check_col.green = 0;
82
+      check_col.blue = 0;
91
+      check_col.blue = 0;
83
+      /* Do proper upscaling from unsigned 8 bit (image data values)
92
+      /* Do proper upscaling from unsigned 8 bit (image data values)
84
+	 to unsigned 16 bit (X color representation). */
93
+	 to unsigned 16 bit (X color representation). */
85
+      ((unsigned short *)&check_col.red)[ci] = (unsigned short)((i << 8) | i);
94
+      ((unsigned short *)&check_col.red)[ci] = (unsigned short)((i << 8) | i);
86
+      if (!XAllocColor(theDisp, DefaultColormap(theDisp,theScreen), &check_col))
95
+      if (theVisual->class == TrueColor)
87
+	FatalError("XAllocColor in screen_init() failed"); /* shouldn't happen */
96
+	XAllocColor(theDisp, theCmap, &check_col);
97
+      else
98
+	xvAllocColor(theDisp, theCmap, &check_col);
88
+      screen_set[ci][i] =
99
+      screen_set[ci][i] =
89
+	(((unsigned short *)&check_col.red)[ci] >> 8) & 0xff;
100
+	(((unsigned short *)&check_col.red)[ci] >> 8) & 0xff;
90
+      XSetForeground(theDisp, check_gc, check_col.pixel);
101
+      XSetForeground(theDisp, check_gc, check_col.pixel);
91
+      XDrawPoint(theDisp, check_map, check_gc, 0, 0);
102
+      XDrawPoint(theDisp, check_map, check_gc, 0, 0);
92
+      check_image = XGetImage(theDisp, check_map, 0, 0, 1, 1,
103
+      check_image = XGetImage(theDisp, check_map, 0, 0, 1, 1,
93
+			      AllPlanes, ZPixmap);
104
+			      AllPlanes, ZPixmap);
94
+      if (!check_image) FatalError("XGetImage in screen_init() failed");
105
+      if (check_image) {
95
+      switch (check_image->bits_per_pixel) {
106
+	switch (check_image->bits_per_pixel) {
96
+      case 8:
107
+	case 8:
97
+	screen_rgb[ci][i] = *(CARD8 *)check_image->data;
108
+	  screen_rgb[ci][i] = *(CARD8 *)check_image->data;
98
+	break;
109
+	  break;
99
+      case 16:
110
+	case 16:
100
+	screen_rgb[ci][i] = *(CARD16 *)check_image->data;
111
+	  screen_rgb[ci][i] = *(CARD16 *)check_image->data;
101
+	break;
112
+	  break;
102
+      case 24:
113
+	case 24:
103
+	screen_rgb[ci][i] =
114
+	  screen_rgb[ci][i] =
104
+	  ((unsigned long)*(CARD8 *)check_image->data << 16) |
115
+	    ((unsigned long)*(CARD8 *)check_image->data << 16) |
105
+	  ((unsigned long)*(CARD8 *)(check_image->data + 1) << 8) |
116
+	    ((unsigned long)*(CARD8 *)(check_image->data + 1) << 8) |
106
+	  (unsigned long)*(CARD8 *)(check_image->data + 2);
117
+	    (unsigned long)*(CARD8 *)(check_image->data + 2);
107
+	break;
118
+	  break;
108
+      case 32:
119
+	case 32:
109
+	screen_rgb[ci][i] = *(CARD32 *)check_image->data;
120
+	  screen_rgb[ci][i] = *(CARD32 *)check_image->data;
110
+	break;
121
+	  break;
122
+	}
123
+	XDestroyImage(check_image);
111
+      }
124
+      }
112
+      XDestroyImage(check_image);
113
+    }
125
+    }
114
+  }
126
+  }
115
+  XFreeGC(theDisp, check_gc);
127
+  XFreeGC(theDisp, check_gc);
Lines 156-162 Link Here
156
+ * current column.  (If we are lucky, those variables are in registers, but
168
+ * current column.  (If we are lucky, those variables are in registers, but
157
+ * even if not, they're probably cheaper to access than array elements are.)
169
+ * even if not, they're probably cheaper to access than array elements are.)
158
+ *
170
+ *
159
+ * The fserrors[] array is indexed [component#][position].
160
+ * We provide (#columns + 2) entries per component; the extra entry at each
171
+ * We provide (#columns + 2) entries per component; the extra entry at each
161
+ * end saves us from special-casing the first and last pixels.
172
+ * end saves us from special-casing the first and last pixels.
162
+ */
173
+ */
Lines 275-281 Link Here
275
 
286
 
276
 #define DO_CROP 0
287
 #define DO_CROP 0
277
 #define DO_ZOOM 1
288
 #define DO_ZOOM 1
278
@@ -1883,33 +2151,17 @@
289
 
290
 
291
 /***********************************/
292
 void Resize(w,h)
293
 int w,h;
294
 {
295
   RANGE(w,1,maxWIDE);  RANGE(h,1,maxHIGH);
296
 
297
   if (HaveSelection()) DrawSelection(0);  /* turn off old rect */
298
 
299
   if (psUp) PSResize();   /* if PSDialog is open, mention size change  */
300
 
301
   /* if same size, and Ximage created, do nothing */
302
   if (w==eWIDE && h==eHIGH && theImage!=NULL) return;
303
 
304
   if (DEBUG) fprintf(stderr,"Resize(%d,%d)  eSIZE=%d,%d  cSIZE=%d,%d\n",
305
 		     w,h,eWIDE,eHIGH,cWIDE,cHIGH);
306
@@ -1866,156 +2128,145 @@
307
     if (!xim) FatalError("couldn't create xim!");
308
 
309
     imagedata = (byte *) malloc((size_t) (xim->bytes_per_line * high));
310
     if (!imagedata) FatalError("couldn't malloc imagedata");
311
 
312
     xim->data = (char *) imagedata;
313
     floydDitherize1(xim, pic24,PIC24, (int) wide, (int) high, NULL,NULL,NULL);
314
 
315
     return xim;
316
   }
317
 
318
 
319
 
320
 
321
   if (theVisual->class == TrueColor || theVisual->class == DirectColor) {
322
 
323
     /************************************************************************/
279
     /* Non-ColorMapped Visuals:  TrueColor, DirectColor                     */
324
     /* Non-ColorMapped Visuals:  TrueColor, DirectColor                     */
280
     /************************************************************************/
325
     /************************************************************************/
281
 
326
 
Lines 311-317 Link Here
311
 
356
 
312
     imagedata = (byte *) malloc((size_t) (high * bperline));
357
     imagedata = (byte *) malloc((size_t) (high * bperline));
313
     if (!imagedata) FatalError("couldn't malloc imagedata");
358
     if (!imagedata) FatalError("couldn't malloc imagedata");
314
@@ -1923,82 +2175,87 @@
359
 
360
     xim->data = (char *) imagedata;
361
 
362
     if (bperpix != 8 && bperpix != 16 && bperpix != 24 && bperpix != 32) {
363
       char buf[128];
364
       sprintf(buf,"Sorry, no code written to handle %d-bit %s",
365
 	      bperpix, "TrueColor/DirectColor displays!");
315
       FatalError(buf);
366
       FatalError(buf);
316
     }
367
     }
317
 
368
 
Lines 363-381 Link Here
363
-	    *ip++ = (xcol>>8)  & 0xff;
414
-	    *ip++ = (xcol>>8)  & 0xff;
364
-	    *ip++ = (xcol>>16) & 0xff;
415
-	    *ip++ = (xcol>>16) & 0xff;
365
-	    *ip++ = (xcol>>24) & 0xff;
416
-	    *ip++ = (xcol>>24) & 0xff;
366
-	  }
367
-	}
368
-
369
-	else if (bperpix == 24) {
370
-	  if (border == MSBFirst) {
371
-	    *ip++ = (xcol>>16) & 0xff;
372
-	    *ip++ = (xcol>>8)  & 0xff;
373
-	    *ip++ =  xcol      & 0xff;
374
-	  }
375
-	  else {  /* LSBFirst */
376
-	    *ip++ =  xcol      & 0xff;
377
-	    *ip++ = (xcol>>8)  & 0xff;
378
-	    *ip++ = (xcol>>16) & 0xff;
379
+#ifdef DO_FIXPIX_SMOOTH
417
+#ifdef DO_FIXPIX_SMOOTH
380
+#if 0
418
+#if 0
381
+    /* If we wouldn't have to save the original pic24 image data,
419
+    /* If we wouldn't have to save the original pic24 image data,
Lines 396-402 Link Here
396
+     * dithering/rendering in a loop using a temporary line buffer.
434
+     * dithering/rendering in a loop using a temporary line buffer.
397
+     */
435
+     */
398
+    if (bperpix < 24) {
436
+    if (bperpix < 24) {
399
+      int alldone = 0;
400
+      FSBUF *fs = fs2_init(wide);
437
+      FSBUF *fs = fs2_init(wide);
401
+      if (fs) {
438
+      if (fs) {
402
+	byte *row_buf = malloc((size_t)wide * 3);
439
+	byte *row_buf = malloc((size_t)wide * 3);
Lines 422-433 Link Here
422
+	      }
459
+	      }
423
+	    }
460
+	    }
424
 	  }
461
 	  }
425
+	  alldone = 1;
462
-	}
426
+	  free(row_buf);
463
+	  free(row_buf);
464
+	  free(fs);
465
 
466
-	else if (bperpix == 24) {
467
-	  if (border == MSBFirst) {
468
-	    *ip++ = (xcol>>16) & 0xff;
469
-	    *ip++ = (xcol>>8)  & 0xff;
470
-	    *ip++ =  xcol      & 0xff;
471
-	  }
472
-	  else {  /* LSBFirst */
473
-	    *ip++ =  xcol      & 0xff;
474
-	    *ip++ = (xcol>>8)  & 0xff;
475
-	    *ip++ = (xcol>>16) & 0xff;
476
-	  }
477
+	  return xim;
427
 	}
478
 	}
428
+	free(fs);
479
+	free(fs);
429
+      }
480
+      }
430
+      if (alldone) return xim;
431
+    }
481
+    }
432
+#endif
482
+#endif
433
+#endif
483
+#endif
Lines 470-472 Link Here
470
 	}
520
 	}
471
       }
521
       }
472
     }
522
     }
523
   }
524
 
525
   else {
526
 
527
     /************************************************************************/
528
     /* CMapped Visuals:  PseudoColor, GrayScale, StaticGray, StaticColor... */
529
     /************************************************************************/
530
 
531
     byte *pic8;
532
     int   bwdith;
533
 
534
     /* in all cases, make an 8-bit version of the image, either using
535
        'black' and 'white', or the stdcmap */
536
 
537
     bwdith = 0;
538
 
539
     if (ncols == 0 && dispDEEP != 1) {   /* do 'black' and 'white' dither */
(-)files/patch-suse-2003-01-27 (+675 lines)
Added Link Here
1
--- xv.c
2
+++ xv.c	2003-01-27 00:03:36.000000000 +0100
3
@@ -146,9 +146,7 @@
4
      rmodeset, gamset, cgamset, perfect, owncmap, rwcolor, stdcmap;
5
 int  nodecor;
6
 double gamval, rgamval, ggamval, bgamval;
7
-
8
-
9
-
10
+winRepositionningInfoST winRepositionningInfo = { 0, 0};
11
 
12
 /*******************************************/
13
 int main(argc, argv)
14
@@ -2125,6 +2145,7 @@
15
     /* if the file is STDIN, write it out to a temp file */
16
 
17
     if (strcmp(filename,STDINSTR)==0) {
18
+      int tmpfd;
19
       FILE *fp;
20
 
21
 #ifndef VMS      
22
@@ -2135,11 +2156,15 @@
23
       mktemp(filename);
24
 
25
       clearerr(stdin);
26
-      fp = fopen(filename,"w");
27
+      tmpfd = open(filename,O_WRONLY|O_CREAT|O_EXCL,S_IRWUSR);
28
+      if (tmpfd < 0) FatalError("openPic(): can't create temporary file");
29
+      fp = fdopen(tmpfd,"w");
30
       if (!fp) FatalError("openPic(): can't write temporary file");
31
     
32
       while ( (i=getchar()) != EOF) putc(i,fp);
33
+      fflush(fp);
34
       fclose(fp);
35
+      close(tmpfd);
36
 
37
       /* and remove it from list, since we can never reload from stdin */
38
       if (strcmp(namelist[0], STDINSTR)==0) deleteFromList(0);
39
@@ -2672,7 +2697,11 @@
40
      to generate the correct exposes (particularly with 'BitGravity' turned
41
      on */
42
 
43
-  if (mainW && !useroot) GenExpose(mainW, 0, 0, (u_int) eWIDE, (u_int) eHIGH);
44
+  /*Brian T. Schellenberger: fix for X 4.2 refresh problem*/
45
+  if (mainW && !useroot) {
46
+    XSync(theDisp, False);
47
+    GenExpose(mainW, 0, 0, (u_int) eWIDE, (u_int) eHIGH);
48
+  }
49
 
50
   return 1;
51
 
52
@@ -2812,7 +2846,8 @@
53
 
54
 #ifdef GS_PATH
55
   else if (strncmp((char *) magicno, "%!",     (size_t) 2)==0 ||
56
-	   strncmp((char *) magicno, "\004%!", (size_t) 3)==0)   rv = RFT_PS;
57
+	   strncmp((char *) magicno, "\004%!", (size_t) 3)==0 ||
58
+	   strncmp((char *) magicno, "%PDF",   (size_t) 4)==0)   rv = RFT_PS;
59
 #endif
60
 
61
 #ifdef HAVE_MAG
62
@@ -2959,6 +2998,7 @@
63
      returns '0' on failure */
64
 
65
   char namez[128], *fname, buf[512];
66
+  int tmpfd;
67
 
68
   fname = name;
69
   namez[0] = '\0';
70
@@ -3047,15 +3090,18 @@
71
      char *src, *dst;
72
 {
73
   char tmpname[128], buffer[8192]; /* XXX */
74
-  int n, eof;
75
+  int n, eof, tmpfd;
76
   FILE *sfp, *dfp;
77
 
78
   sprintf(dst, "%s/xvmXXXXXX", tmpdir);
79
   mktemp(dst);
80
+  tmpfd = open(dst,O_WRONLY|O_CREAT|O_EXCL,S_IRWUSR);
81
+  if (tmpfd < 0) FatalError("RemoveMacbinary(): can't create temporary file");
82
+
83
   SetISTR(ISTR_INFO, "Removing MacBinary...");
84
 
85
   sfp = xv_fopen(src, "r"); 
86
-  dfp = xv_fopen(dst, "w"); 
87
+  dfp = fdopen(tmpfd, "w"); 
88
   if (!sfp || !dfp) {
89
     SetISTR(ISTR_INFO, "Unable to remove a InfoFile header form '%s'.", src);
90
     Warning();
91
@@ -3067,7 +3113,9 @@
92
   if (eof = feof(sfp))
93
     fwrite(buffer, 1, n, dfp);
94
   fclose(sfp);
95
+  fflush(dfp);
96
   fclose(dfp);
97
+  close(tmpfd);
98
   if (!eof) {
99
     SetISTR(ISTR_INFO, "Unable to remove a InfoFile header form '%s'.", src);
100
     Warning();
101
@@ -3199,7 +3247,7 @@
102
    */
103
 
104
   char fullcmd[512], tmpname[64], str[512];
105
-  int i;
106
+  int i, tmpfd;
107
 
108
   if (!cmd || (strlen(cmd) < (size_t) 2)) return 1;
109
 
110
@@ -3210,6 +3258,9 @@
111
     ErrPopUp(str, "\nHow unlikely!");
112
     return 1;
113
   }
114
+  tmpfd = open(tmpname,O_WRONLY|O_CREAT|O_EXCL,S_IRWUSR);
115
+  if (tmpfd < 0) FatalError("openPic(): can't create temporary file");
116
+  close(tmpfd);
117
 
118
   /* build command */
119
   strcpy(fullcmd, cmd+1);  /* skip the leading '!' character in cmd */
120
--- xv.h
121
+++ xv.h	2003-01-27 00:03:36.000000000 +0100
122
@@ -310,7 +294,9 @@
123
 #  endif
124
 #endif
125
 
126
-
127
+#ifndef		S_IRWUSR
128
+#  define	S_IRWUSR	(S_IRUSR|S_IWRITE)
129
+#endif
130
 
131
 #ifndef MAXPATHLEN
132
 #  define MAXPATHLEN 256
133
@@ -813,6 +811,13 @@
134
 #define WHERE
135
 #endif
136
 
137
+/* Needed for repositionning with negative geometries */
138
+typedef struct {
139
+  int negativeX;
140
+  int negativeY;
141
+} winRepositionningInfoST;
142
+extern winRepositionningInfoST winRepositionningInfo;
143
+
144
 typedef unsigned char byte;
145
 
146
 typedef struct scrl { 
147
--- xvdir.c
148
+++ xvdir.c	2003-01-27 00:03:36.000000000 +0100
149
@@ -80,7 +83,7 @@
150
 			       "PIC",
151
 #endif /* HAVE_PIC */
152
 #ifdef HAVE_MAKI
153
-			       "MAKI",
154
+			       "MAKI (640x400 only)",
155
 #endif /* HAVE_MAKI */
156
 #ifdef HAVE_PI
157
 			       "PI",
158
--- xvevent.c
159
+++ xvevent.c	2003-01-27 00:03:36.000000000 +0100
160
@@ -64,6 +64,8 @@
161
 
162
 static void   annotatePic      PARM((void));
163
 
164
+static int    debkludge_offx;
165
+static int    debkludge_offy;
166
 
167
 /****************/
168
 int EventLoop()
169
@@ -676,6 +694,29 @@
170
 	p_offy = xwa.y;
171
       }
172
 
173
+      /* Gather info to keep right border inside */
174
+      {
175
+	Window current;
176
+	Window root_r;
177
+	Window parent_r;
178
+	Window *children_r;
179
+	int nchildren_r;
180
+	XWindowAttributes xwa;
181
+
182
+	parent_r=mainW;
183
+	current=mainW;
184
+	do {
185
+	  current=parent_r;
186
+	  XQueryTree(theDisp, current, &root_r, &parent_r,
187
+		     &children_r, &nchildren_r);
188
+	  if (children_r!=NULL) {
189
+	    XFree(children_r);
190
+	  }
191
+	} while(parent_r!=root_r);
192
+	XGetWindowAttributes(theDisp, current, &xwa);
193
+	debkludge_offx=eWIDE-xwa.width+p_offx;
194
+	debkludge_offy=eHIGH-xwa.height+p_offy;
195
+      }
196
       
197
       /* move window around a bit... */
198
       {
199
@@ -2078,6 +2127,26 @@
200
   if (xwa->width  < dispWIDE && xwc.x < p_offx) xwc.x = p_offx;
201
   if (xwa->height < dispHIGH && xwc.y < p_offy) xwc.y = p_offy;
202
 
203
+  /* Try to keep bottom right decorations inside */
204
+  if (xwc.x+eWIDE-debkludge_offx>dispWIDE) {
205
+    xwc.x=dispWIDE-eWIDE+debkludge_offx;
206
+    if (xwc.x<0) xwc.x=0;
207
+  }
208
+  if (xwc.y+eHIGH-debkludge_offy>dispHIGH) {
209
+    xwc.y=dispHIGH-eHIGH+debkludge_offy;
210
+    if (xwc.y<0) xwc.y=0;
211
+  }
212
+
213
+  /* In case of negative offset for first image */
214
+  if (winRepositionningInfo.negativeX) {
215
+    xwc.x+=winRepositionningInfo.negativeX;
216
+    winRepositionningInfo.negativeX=0;
217
+  }
218
+  if (winRepositionningInfo.negativeY) {
219
+    xwc.y+=winRepositionningInfo.negativeY;
220
+    winRepositionningInfo.negativeY=0;
221
+  }
222
+
223
   xwc.width  = xwa->width;
224
   xwc.height = xwa->height;
225
 
226
--- xvfits.c
227
+++ xvfits.c	2003-01-27 00:03:36.000000000 +0100
228
@@ -14,7 +14,7 @@
229
  * provided "as is" without express or implied warranty.
230
  */
231
 
232
-
233
+#define  NEEDSDIR /* for S_IRUSR|S_IWUSR */
234
 #include "xv.h"
235
 
236
 #define NCARDS    (36)
237
@@ -223,7 +223,7 @@
238
    * If there was a problem writing files, then a error message will be set.
239
    */
240
   
241
-  int   i, np=nx * ny, ioerror, nwrt;
242
+  int   i, np=nx * ny, ioerror, nwrt, tmpfd;
243
   FILE *fp;
244
   char *error;
245
   byte *work;
246
@@ -246,7 +246,12 @@
247
 
248
   for (i=0; i < nz && !error; i++) {
249
     sprintf(filename, "%s%d", basename, i+1);
250
-    fp = xv_fopen(filename, "w");
251
+    tmpfd = open(filename,O_WRONLY|O_CREAT|O_EXCL,S_IRWUSR);
252
+    if (tmpfd < 0) {
253
+      error = "Unable to open temporary file";
254
+      break;
255
+    }
256
+    fp = fdopen(tmpfd, "w");
257
     if (!fp) {
258
       error = "Unable to open temporary file";
259
       break;
260
@@ -254,13 +259,17 @@
261
     
262
     if (wrheader(fp, nx, ny, comment)) {
263
       error = "I/O error writing temporary file";
264
+      fflush(fp);
265
       fclose(fp);
266
+      close(tmpfd);
267
       unlink(filename);
268
       break;
269
     }
270
 
271
     nwrt = fwrite(image+i*np, sizeof(byte), (size_t) np, fp);
272
+    fflush(fp);
273
     fclose(fp);
274
+    close(tmpfd);
275
 
276
     if (nwrt == 0) {  /* failed to write any data */
277
       error = "I/O error writing temporary file";
278
--- xvimage.c
279
+++ xvimage.c	2003-01-27 00:03:36.000000000 +0100
280
@@ -21,6 +21,7 @@
281
  *            int  LoadPad(pinfo, fname);
282
  */
283
 
284
+#define  NEEDSDIR             /* for S_IRUSR|S_IWUSR */
285
 #include "copyright.h"
286
 
287
 #include "xv.h"
288
@@ -2927,7 +2930,7 @@
289
      char *str;
290
      int   wide, high, opaque,omode;
291
 {
292
-  int i;
293
+  int i, tmpfd;
294
   byte *bgpic24;
295
   char syscmd[512], fname[128], errstr[512];
296
   PICINFO pinfo;
297
@@ -2949,6 +2952,13 @@
298
   strcpy(fname, "Sys$Disk:[]xvuXXXXXX");
299
 #endif
300
   mktemp(fname);
301
+  tmpfd = open(fname, O_WRONLY|O_CREAT|O_EXCL,S_IRWUSR);
302
+  if (tmpfd < 0) {
303
+    sprintf(errstr, "Error: can't create temporary file %s", fname);
304
+    ErrPopUp(errstr, "\nDoh!");
305
+    return 0;
306
+  }
307
+  close(tmpfd);
308
 
309
   /* run bggen to generate the background */
310
   sprintf(syscmd, "bggen -g %dx%d %s > %s", wide, high, str, fname);
311
--- xvmaki.c
312
+++ xvmaki.c	2003-01-27 00:03:36.000000000 +0100
313
@@ -355,8 +355,12 @@
314
 	return -1;
315
     }
316
     
317
-    if(w != 640 || h != 400)
318
+    if(w != 640 || h != 400) {
319
+        char  str[512];
320
+        sprintf(str,"MAKI: %s Should be 640x400", maki_msgs[MAKI_SIZE]);
321
+	ErrPopUp(str, "\nBummer!");
322
 	maki_error(mi, MAKI_SIZE);
323
+    }
324
     
325
     maki.fp = fp;
326
     maki.width = w;
327
@@ -669,6 +673,7 @@
328
 static void maki_init_info(mi)
329
     struct maki_info *mi;
330
 {
331
+    xvbzero((char *)mi, sizeof(struct maki_info));
332
     mi->fp = NULL;
333
     mi->fsize = 0;
334
     mi->x0 = mi->y0 = mi->x1 = mi->y1 = 0;
335
--- xvpds.c
336
+++ xvpds.c	2003-01-27 00:03:36.000000000 +0100
337
@@ -102,7 +102,7 @@
338
  * This software is provided "as is" without any express or implied warranty.
339
  */
340
 
341
-
342
+#define  NEEDSDIR       /* for S_IRUSR|S_IWUSR */
343
 #include "xv.h"
344
 
345
 #ifdef HAVE_PDS
346
@@ -250,7 +250,7 @@
347
 {
348
   /* returns '1' on success, '0' on failure */
349
 
350
-  int tempnum;
351
+  int tempnum, tmpfd;
352
   FILE	*zf;
353
   static int isfixed,teco,i,j,itype,vaxbyte,
354
              recsize,hrecsize,irecsize,isimage,labelrecs,labelsofar,
355
@@ -690,6 +690,12 @@
356
 #ifndef VMS
357
     sprintf(pdsuncompfname,"%s/xvhuffXXXXXX", tmpdir);
358
     mktemp(pdsuncompfname);
359
+    tmpfd = open(pdsuncompfname,O_WRONLY|O_CREAT|O_EXCL,S_IRWUSR);
360
+    if (tmpfd < 0) {
361
+	SetISTR(ISTR_WARNING,"Unable to create temporarly file.");
362
+	return 0;
363
+    }
364
+    close(tmpfd);
365
     sprintf(scanbuff,"%s %s - 4 >%s",PDSUNCOMP,fname,pdsuncompfname);
366
 #else
367
     strcpy(pdsuncompfname,"sys$disk:[]xvhuffXXXXXX");
368
--- xvps.c
369
+++ xvps.c	2003-01-27 00:03:36.000000000 +0100
370
@@ -1564,7 +1564,7 @@
371
   /* build command string */
372
 
373
 #ifndef VMS  /* VMS needs quotes around mixed case command lines */
374
-  sprintf(tmp, "%s -sDEVICE=%s -r%d -q -dNOPAUSE -sOutputFile=%s%%d ",
375
+  sprintf(tmp, "%s -sDEVICE=%s -r%d -q -dSAFER -dNOPAUSE -sOutputFile=%s%%d ",
376
 	  GS_PATH, gsDev, gsRes, tmpname);
377
 #else
378
   sprintf(tmp, 
379
--- xvtiff.c
380
+++ xvtiff.c	2003-01-27 00:03:36.000000000 +0100
381
@@ -5,6 +5,7 @@
382
  * LoadTIFF(fname, numcols, quick)  -  load a TIFF file
383
  */
384
 
385
+#define  NEEDSDIR       /* for S_IRUSR|S_IWUSR */
386
 #ifndef va_start
387
 # define NEEDSARGS
388
 #endif
389
@@ -56,7 +89,7 @@
390
     return 0;
391
   }
392
 
393
-  fseek(fp, 0L, 2);
394
+  fseek(fp, 0L, SEEK_END);
395
   filesize = ftell(fp);
396
   fclose(fp);
397
 
398
@@ -1065,7 +1308,7 @@
399
      int fromskew, toskew;
400
 {
401
   while (h-- > 0) {
402
-    UNROLL8(w,0, *cp++ = PALmap[*pp++][0]);
403
+    UNROLL8(w,, *cp++ = PALmap[*pp++][0]);
404
     cp += toskew;
405
     pp += fromskew;
406
   }
407
@@ -1262,7 +1504,7 @@
408
     }
409
   } else {
410
     while (h-- > 0) {
411
-      UNROLL8(w,0,
412
+      UNROLL8(w,,
413
 	      *cp++ = pp[0];
414
 	      *cp++ = pp[1];
415
 	      *cp++ = pp[2];
416
@@ -1335,7 +1577,7 @@
417
     }
418
   } else {
419
     while (h-- > 0) {
420
-      UNROLL8(w,0,
421
+      UNROLL8(w,,
422
 	      *cp++ = *r++;
423
 	      *cp++ = *g++;
424
 	      *cp++ = *b++;
425
--- xvtiffwr.c
426
+++ xvtiffwr.c	2003-01-27 00:03:36.000000000 +0100
427
@@ -78,6 +78,9 @@
428
       TIFFSetField(tif, TIFFTAG_GROUP3OPTIONS,
429
 	  GROUP3OPT_2DENCODING+GROUP3OPT_FILLBITS);
430
 
431
+  if (comp == COMPRESSION_LZW)
432
+      TIFFSetField(tif, TIFFTAG_PREDICTOR, 2);
433
+
434
   TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
435
   TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 1);
436
   TIFFSetField(tif, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT);
437
--- xvvd.c
438
+++ xvvd.c	2003-01-27 00:03:36.000000000 +0100
439
@@ -793,7 +794,7 @@
440
        returns '0' on failure */
441
 
442
     char namez[128], *fname, buf[512], tmp[HEADERSIZE];
443
-    int n;
444
+    int n, tmpfd;
445
     FILE *pfp, *tfp;
446
   
447
     fname = name;
448
@@ -834,10 +835,17 @@
449
 	Warning();
450
 	return 0;
451
     }
452
-    if ((tfp = fopen(uncompname, "w")) == NULL) {
453
+    if ((tmpfd = open(uncompname,O_WRONLY|O_CREAT|O_EXCL,S_IRWUSR)) < 0) {
454
+	SetISTR(ISTR_INFO, "Unable to create temporarly file.",
455
+		BaseName(uncompname));
456
+	Warning();
457
+	pclose(pfp);
458
+    }
459
+    if ((tfp = fdopen(tmpfd, "w")) == NULL) {
460
 	SetISTR(ISTR_INFO, "Unable to create temporarly file.",
461
 		BaseName(uncompname));
462
 	Warning();
463
+	close(tmpfd);
464
 	pclose(pfp);
465
 	return 0;
466
     }
467
@@ -846,11 +854,15 @@
468
 		BaseName(fname));
469
 	Warning();
470
 	pclose(pfp);
471
+	fflush(tfp);
472
 	fclose(tfp);
473
+	close(tmpfd);
474
 	return 0;
475
     }
476
     fwrite(tmp, 1, n, tfp);
477
+    fflush(tfp);
478
     fclose(tfp);
479
+    close(tmpfd);
480
     pclose(pfp);
481
     
482
     /* if we renamed the file to end with a .Z for the sake of 'uncompress', 
483
--- xvxpm.c
484
+++ xvxpm.c	2003-01-27 00:03:36.000000000 +0100
485
@@ -77,96 +77,104 @@
486
   hentry  *clmp;		/* colormap hash-table */
487
   hentry  *c_sptr;		/* cmap hash-table search pointer*/
488
   XColor   col;
489
-  
490
+
491
   bname = BaseName(fname);
492
   fp = fopen(fname, "r");
493
   if (!fp)
494
     return (XpmLoadError(bname, "couldn't open file"));
495
-  
496
+
497
   if (DEBUG)
498
     printf("LoadXPM(): Loading xpm from %s\n", fname);
499
-  
500
+
501
   fseek(fp, 0L, 2);
502
   filesize = ftell(fp);
503
   fseek(fp, 0L, 0);
504
-  
505
+
506
   bufchar = -2;
507
   in_quote = FALSE;
508
-  
509
+
510
   /* Read in the values line.  It is the first string in the
511
    * xpm, and contains four numbers.  w, h, num_colors, and
512
    * chars_per_pixel. */
513
-  
514
+
515
   /* First, get to the first string */
516
   while (((c = XpmGetc(fp))!=EOF) && (c != '"')) ;
517
   line_pos = 0;
518
-  
519
+
520
   /* Now, read in the string */
521
   while (((c = XpmGetc(fp))!=EOF) && (line_pos < VALUES_LEN) && (c != '"')) {
522
     values[line_pos++] = c;
523
   }
524
   if (c != '"')
525
     return (XpmLoadError(bname, "error parsing values line"));
526
-  
527
+
528
   values[line_pos] = '\0';
529
   sscanf(values, "%d%d%d%d", &w, &h, &nc, &cpp);
530
   if (nc <= 0 || cpp <= 0)
531
     return (XpmLoadError(bname, "No colours in Xpm?"));
532
-  
533
+
534
   if (nc > 256)
535
     pinfo->type = PIC24;
536
   else
537
     pinfo->type = PIC8;
538
-  
539
+
540
   if (DEBUG)
541
     printf("LoadXPM(): reading a %dx%d image (%d colors)\n", w, h, nc);
542
-  
543
+
544
   /* We got this far... */
545
   WaitCursor();
546
-  
547
+
548
   if (!hash_init(nc))
549
     return (XpmLoadError(bname, "Not enough memory to hash colormap"));
550
-  
551
+
552
   clmp = (hentry *) malloc(nc * sizeof(hentry)); /* Holds the colormap */
553
   if (pinfo->type == PIC8) pic = (byte *) malloc((size_t) (w*h));
554
                       else pic = (byte *) malloc((size_t) (w*h*3));
555
-  
556
+
557
   if (!clmp || !pic)
558
     return (XpmLoadError(bname, "Not enough memory to load pixmap"));
559
-  
560
+
561
   c_sptr = clmp;
562
   i_sptr = pic;
563
-  
564
+
565
   /* initialize the 'hex' array for zippy ASCII-hex -> int conversion */
566
-  
567
+
568
   for (i = 0 ; i < 256 ; i++)   hex[i] = 0;
569
   for (i = '0'; i <= '9' ; i++) hex[i] = i - '0';
570
   for (i = 'a'; i <= 'f' ; i++) hex[i] = i - 'a' + 10;
571
   for (i = 'A'; i <= 'F' ; i++) hex[i] = i - 'A' + 10;
572
-  
573
+
574
   /* Again, we've made progress. */
575
   WaitCursor();
576
-  
577
+
578
   /* Now, we need to read the colormap. */
579
   pinfo->colType = F_BWDITHER;
580
   for (i = 0 ; i < nc ; i++) {
581
     while (((c = XpmGetc(fp))!=EOF) && (c != '"')) ;
582
     if (c != '"')
583
       return (XpmLoadError(bname, "Error reading colormap"));
584
-    
585
+
586
     for (j = 0 ; j < cpp ; j++)
587
       c_sptr->token[j] = XpmGetc(fp);
588
     c_sptr->token[j] = '\0';
589
-    
590
+
591
     while (((c = XpmGetc(fp))!=EOF) && ((c == ' ') || (c == '\t'))) ;
592
     if (c == EOF)		/* The failure condition of getc() */
593
       return (XpmLoadError(bname, "Error parsing colormap line"));
594
-    
595
+
596
     do {
597
       char  key[3];
598
-      char  color[40];	/* Need to figure a good size for this... */
599
+      char  color[80];	/* Need to figure a good size for this... */
600
       short hd;		/* Hex digits per R, G, or B */
601
-      
602
+
603
+/*
604
+ *  Problem with spaces in color names
605
+ *
606
+ *    X s Color Name m Other Name c Last Name
607
+ *
608
+ *  ... this parser doesn't find `Any Name'
609
+ */
610
+
611
       for (j=0; j<2 && (c != ' ') && (c != '\t') && (c != EOF); j++) {
612
 	key[j] = c;
613
 	c = XpmGetc(fp);
614
@@ -177,7 +185,7 @@
615
       if (c == EOF)	/* The failure condition of getc() */
616
 	return (XpmLoadError(bname, "Error parsing colormap line"));
617
 
618
-      for (j=0; j<39 && (c!=' ') && (c!='\t') && (c!='"') && c!=EOF; j++) {
619
+      for (j=0; j<79 && (c!=' ') && (c!='\t') && (c!='"') && c!=EOF; j++) {
620
 	color[j] = c;
621
 	c = XpmGetc(fp);
622
       }
623
@@ -236,13 +244,13 @@
624
       else {      /* 'None' or unrecognized color spec */
625
 	int rgb;
626
 
627
-	if (strcmp(color, "None") == 0) rgb = 0xb2c0dc;  /* infobg */
628
+	if (strcasecmp(color, "None") == 0) rgb = 0xb2c0dc;  /* infobg */
629
 	else {
630
 	  SetISTR(ISTR_INFO, "%s:  unknown color spec '%s'", bname, color);
631
 	  Timer(1000);
632
 	  rgb = 0x808080;
633
 	}
634
-	
635
+
636
 	if (pinfo->type == PIC8) {
637
 	  pinfo->r[i] = (rgb>>16) & 0xff;
638
 	  pinfo->g[i] = (rgb>> 8) & 0xff;
639
@@ -309,28 +317,29 @@
640
 	*i_sptr++ = mapentry->cv_rgb[2];
641
       }
642
     }  /* for ( j < w ) */
643
-    (void)XpmGetc(fp);		/* Throw away the close " */
644
-  
645
+    while (((c = XpmGetc(fp))!=EOF) &&	/* Throw away the close " and */
646
+	   (c != '"')) ;		/* erase all remaining pixels */
647
+
648
     if (!(i%7)) WaitCursor();
649
   }  /* for ( i < h ) */
650
-  
651
+
652
   pinfo->pic = pic;
653
   pinfo->normw = pinfo->w = w;
654
   pinfo->normh = pinfo->h = h;
655
   pinfo->frmType = F_XPM;
656
 
657
   if (DEBUG) printf("LoadXPM(): pinfo->colType is %d\n", pinfo->colType);
658
-  
659
+
660
   sprintf(pinfo->fullInfo, "Xpm v3 Pixmap (%ld bytes)", filesize);
661
   sprintf(pinfo->shrtInfo, "%dx%d Xpm.", w, h);
662
   pinfo->comment = (char *)NULL;
663
-  
664
+
665
   hash_destroy();
666
   free(clmp);
667
-  
668
+
669
   if (fp != stdin)
670
     fclose(fp);
671
-  
672
+
673
   return(1);
674
 }
675
 
(-)files/patch-suse-2004-07-28 (+195 lines)
Added Link Here
1
--- xvbmp.c
2
+++ xvbmp.c	Wed Jul 28 15:16:05 2004
3
@@ -32,7 +32,7 @@
4
 static int   loadBMP1   PARM((FILE *, byte *, u_int, u_int));
5
 static int   loadBMP4   PARM((FILE *, byte *, u_int, u_int, u_int));
6
 static int   loadBMP8   PARM((FILE *, byte *, u_int, u_int, u_int));
7
-static int   loadBMP24  PARM((FILE *, byte *, u_int, u_int));
8
+static int   loadBMP24  PARM((FILE *, byte *, u_int, u_int, u_int));
9
 static u_int getshort   PARM((FILE *));
10
 static u_int getint     PARM((FILE *));
11
 static void  putshort   PARM((FILE *, int));
12
@@ -127,7 +127,8 @@
13
 
14
 
15
   /* error checking */
16
-  if ((biBitCount!=1 && biBitCount!=4 && biBitCount!=8 && biBitCount!=24) || 
17
+  if ((biBitCount!=1 && biBitCount!=4 && biBitCount!=8 && 
18
+       biBitCount!=24 && biBitCount!=32) || 
19
       biPlanes!=1 || biCompression>BI_RLE4) {
20
 
21
     sprintf(buf,"Bogus BMP File!  (bitCount=%d, Planes=%d, Compression=%d)",
22
@@ -137,7 +138,8 @@
23
     goto ERROR;
24
   }
25
 
26
-  if (((biBitCount==1 || biBitCount==24) && biCompression != BI_RGB) ||
27
+  if (((biBitCount==1 || biBitCount==24 || biBitCount==32)
28
+       && biCompression != BI_RGB) ||
29
       (biBitCount==4 && biCompression==BI_RLE8) ||
30
       (biBitCount==8 && biCompression==BI_RLE4)) {
31
 
32
@@ -159,7 +161,7 @@
33
   }
34
 
35
   /* load up colormap, if any */
36
-  if (biBitCount!=24) {
37
+  if (biBitCount!=24 && biBitCount!=32) {
38
     int i, cmaplen;
39
 
40
     cmaplen = (biClrUsed) ? biClrUsed : 1 << biBitCount;
41
@@ -197,7 +199,7 @@
42
 
43
   /* create pic8 or pic24 */
44
 
45
-  if (biBitCount==24) {
46
+  if (biBitCount==24 || biBitCount==32) {
47
     pic24 = (byte *) calloc((size_t) biWidth * biHeight * 3, (size_t) 1);
48
     if (!pic24) return (bmpError(bname, "couldn't malloc 'pic24'"));
49
   }
50
@@ -212,16 +214,18 @@
51
   if      (biBitCount == 1) rv = loadBMP1(fp,pic8,biWidth,biHeight);
52
   else if (biBitCount == 4) rv = loadBMP4(fp,pic8,biWidth,biHeight,
53
 					  biCompression);
54
-  else if (biBitCount == 8) rv = loadBMP8(fp,pic8,biWidth,biHeight,
55
+  else if (biBitCount == 8) rv = loadBMP8(fp,pic8,biWidth,biHeight, 
56
 					  biCompression);
57
-  else                      rv = loadBMP24(fp,pic24,biWidth,biHeight);
58
+  else                      rv = loadBMP24(fp,pic24,biWidth,biHeight,
59
+					   biBitCount);
60
+
61
 
62
   if (rv) bmpError(bname, "File appears truncated.  Winging it.\n");
63
 
64
   fclose(fp);
65
 
66
 
67
-  if (biBitCount == 24) {
68
+  if (biBitCount == 24 || biBitCount == 32) {
69
     pinfo->pic  = pic24;
70
     pinfo->type = PIC24;
71
   }
72
@@ -264,12 +268,13 @@
73
      u_int  w,h;
74
 {
75
   int   i,j,c,bitnum,padw;
76
-  byte *pp;
77
+  byte *pp = pic8 + ((h - 1) * w);
78
+  size_t l = w*h;
79
 
80
   c = 0;
81
   padw = ((w + 31)/32) * 32;  /* 'w', padded to be a multiple of 32 */
82
 
83
-  for (i=h-1; i>=0; i--) {
84
+  for (i=h-1; i>=0 && (pp - pic8 <= l); i--) {
85
     pp = pic8 + (i * w);
86
     if ((i&0x3f)==0) WaitCursor();
87
     for (j=bitnum=0; j<padw; j++,bitnum++) {
88
@@ -298,8 +303,8 @@
89
      u_int  w,h,comp;
90
 {
91
   int   i,j,c,c1,x,y,nybnum,padw,rv;
92
-  byte *pp;
93
-  
94
+  byte *pp = pic8 + ((h - 1) * w);
95
+  size_t l = w*h;
96
   
97
   rv = 0;
98
   c = c1 = 0;
99
@@ -307,7 +312,7 @@
100
   if (comp == BI_RGB) {   /* read uncompressed data */
101
     padw = ((w + 7)/8) * 8; /* 'w' padded to a multiple of 8pix (32 bits) */
102
     
103
-    for (i=h-1; i>=0; i--) {
104
+    for (i=h-1; i>=0 && (pp - pic8 <= l); i--) {
105
       pp = pic8 + (i * w);
106
       if ((i&0x3f)==0) WaitCursor();
107
       
108
@@ -335,7 +340,7 @@
109
       
110
       if (c) {                                   /* encoded mode */
111
 	c1 = getc(fp);
112
-	for (i=0; i<c; i++,x++,pp++) 
113
+	for (i=0; i<c && (pp - pic8 <= l); i++,x++,pp++) 
114
 	  *pp = (i&1) ? (c1 & 0x0f) : ((c1>>4)&0x0f);
115
       }
116
       
117
@@ -355,7 +360,7 @@
118
 	}
119
 	
120
 	else {                                   /* absolute mode */
121
-	  for (i=0; i<c; i++, x++, pp++) {
122
+	  for (i=0; i<c && (pp - pic8 <= l); i++, x++, pp++) {
123
 	    if ((i&1) == 0) c1 = getc(fp);
124
 	    *pp = (i&1) ? (c1 & 0x0f) : ((c1>>4)&0x0f);
125
 	  }
126
@@ -384,14 +389,15 @@
127
      u_int  w,h,comp;
128
 {
129
   int   i,j,c,c1,padw,x,y,rv;
130
-  byte *pp;
131
+  byte *pp = pic8 + ((h - 1) * w);
132
+  size_t l = w*h;
133
   
134
   rv = 0;
135
 
136
   if (comp == BI_RGB) {   /* read uncompressed data */
137
     padw = ((w + 3)/4) * 4; /* 'w' padded to a multiple of 4pix (32 bits) */
138
 
139
-    for (i=h-1; i>=0; i--) {
140
+    for (i=h-1; i>=0 && (pp - pic8 <= l); i--) {
141
       pp = pic8 + (i * w);
142
       if ((i&0x3f)==0) WaitCursor();
143
 
144
@@ -412,7 +418,7 @@
145
 
146
       if (c) {                                   /* encoded mode */
147
 	c1 = getc(fp);
148
-	for (i=0; i<c; i++,x++,pp++) *pp = c1;
149
+	for (i=0; i<c && (pp - pic8 <= l); i++,x++,pp++) *pp = c1;
150
       }
151
 
152
       else {    /* c==0x00  :  escape codes */
153
@@ -431,7 +437,7 @@
154
 	}
155
 
156
 	else {                                   /* absolute mode */
157
-	  for (i=0; i<c; i++, x++, pp++) {
158
+	  for (i=0; i<c && (pp - pic8 <= l); i++, x++, pp++) {
159
 	    c1 = getc(fp);
160
 	    *pp = c1;
161
 	  }
162
@@ -454,19 +460,21 @@
163
 
164
 
165
 /*******************************************/
166
-static int loadBMP24(fp, pic24, w, h)
167
+static int loadBMP24(fp, pic24, w, h, bits)
168
      FILE *fp;
169
      byte *pic24;
170
-     u_int  w,h;
171
+     u_int  w,h, bits;
172
 {
173
   int   i,j,padb,rv;
174
-  byte *pp;
175
+  byte *pp = pic24 + ((h - 1) * w * 3);
176
+  size_t l = w*h*3;
177
 
178
   rv = 0;
179
 
180
   padb = (4 - ((w*3) % 4)) & 0x03;  /* # of pad bytes to read at EOscanline */
181
+  if (bits==32) padb = 0;
182
 
183
-  for (i=h-1; i>=0; i--) {
184
+  for (i=h-1; i>=0 && (pp - pic24 <= l); i--) {
185
     pp = pic24 + (i * w * 3);
186
     if ((i&0x3f)==0) WaitCursor();
187
     
188
@@ -474,6 +482,7 @@
189
       pp[2] = getc(fp);   /* blue */
190
       pp[1] = getc(fp);   /* green */
191
       pp[0] = getc(fp);   /* red */
192
+      if (bits==32) getc(fp);
193
       pp += 3;
194
     }
195
 
(-)files/patch-suse-2004-08-24 (+138 lines)
Added Link Here
1
--- xvbmp.c
2
+++ xvbmp.c	Tue Aug 24 12:42:52 2004
3
@@ -129,7 +129,9 @@
4
   /* error checking */
5
   if ((biBitCount!=1 && biBitCount!=4 && biBitCount!=8 && 
6
        biBitCount!=24 && biBitCount!=32) || 
7
-      biPlanes!=1 || biCompression>BI_RLE4) {
8
+       biPlanes!=1 || biCompression>BI_RLE4 ||
9
+       biWidth<= 0 || biHeight <= 0 ||
10
+       (biClrUsed && biClrUsed > (1 << biBitCount))) {
11
 
12
     sprintf(buf,"Bogus BMP File!  (bitCount=%d, Planes=%d, Compression=%d)",
13
 	    biBitCount, biPlanes, biCompression);
14
@@ -159,6 +161,9 @@
15
     
16
     bPad = bfOffBits - (biSize + 14);
17
   }
18
+
19
+  if (biClrUsed > (1 << biBitCount))
20
+    biClrUsed = (1 << biBitCount);
21
 
22
   /* load up colormap, if any */
23
   if (biBitCount!=24 && biBitCount!=32) {
24
--- xviris.c
25
+++ xviris.c	Tue Aug 24 13:01:42 2004
26
@@ -267,6 +267,12 @@
27
 
28
     rlebuflen = 2 * xsize + 10;
29
     tablen    = ysize * zsize;
30
+
31
+    if (rlebuflen <= 0 || tablen <= 0 || (tablen * sizeof(long)) < 0) {
32
+      loaderr = "Bogus IRIS File!";
33
+      return (byte *)NULL;
34
+    }
35
+
36
     starttab  = (u_long *) malloc((size_t) tablen * sizeof(long));
37
     lengthtab = (u_long *) malloc((size_t) tablen * sizeof(long));
38
     rledat    = (byte *)   malloc((size_t) rlebuflen);
39
--- xvpcx.c
40
+++ xvpcx.c	Tue Aug 24 13:12:15 2004
41
@@ -222,7 +222,14 @@
42
   byte *image;
43
   
44
   /* note:  overallocation to make life easier... */
45
-  image = (byte *) malloc((size_t) (pinfo->h + 1) * pinfo->w + 16);
46
+  int count = (pinfo->h + 1) * pinfo->w + 16;
47
+
48
+  if (count <= 0 || pinfo->h <= 0 || pinfo->w <= 0) {
49
+    pcxError(fname, "Bogus PCX file!!");
50
+    return (0);
51
+  }
52
+
53
+  image = (byte *) malloc((size_t) count);
54
   if (!image) FatalError("Can't alloc 'image' in pcxLoadImage8()");
55
   
56
   xvbzero((char *) image, (size_t) ((pinfo->h+1) * pinfo->w + 16));
57
@@ -250,17 +257,25 @@
58
 {
59
   byte *pix, *pic24, scale[256];
60
   int   c, i, j, w, h, maxv, cnt, planes, bperlin, nbytes;
61
+  int count;
62
   
63
   w = pinfo->w;  h = pinfo->h;
64
   
65
   planes = (int) hdr[PCX_PLANES];
66
   bperlin = hdr[PCX_BPRL] + ((int) hdr[PCX_BPRH]<<8);
67
   
68
+  count = w*h*planes;
69
+
70
+  if (count <= 0 || planes <= 0 || w <= 0 || h <= 0) {
71
+    pcxError(fname, "Bogus PCX file!!");
72
+    return (0);
73
+  }
74
+
75
   /* allocate 24-bit image */
76
-  pic24 = (byte *) malloc((size_t) w*h*planes);
77
+  pic24 = (byte *) malloc((size_t) count);
78
   if (!pic24) FatalError("couldn't malloc 'pic24'");
79
   
80
-  xvbzero((char *) pic24, (size_t) w*h*planes);
81
+  xvbzero((char *) pic24, (size_t) count);
82
   
83
   maxv = 0;
84
   pix = pinfo->pic = pic24;
85
@@ -268,6 +283,12 @@
86
   j = 0;      /* bytes per line, in this while loop */
87
   nbytes = bperlin*h*planes;
88
  
89
+  if (nbytes < 0) {
90
+    pcxError(fname, "Bogus PCX file!!");
91
+    free(pic24);
92
+    return (0);
93
+  }
94
+
95
   while (nbytes > 0 && (c = getc(fp)) != EOF) {
96
     if ((c & 0xC0) == 0xC0) {   /* have a rep. count */
97
       cnt = c & 0x3F;
98
--- xvpm.c
99
+++ xvpm.c	Tue Aug 24 13:16:43 2004
100
@@ -119,6 +119,9 @@
101
 
102
   isize = pm_isize(&thePic);
103
 
104
+  if (isize <= 0)
105
+    return pmError(bname, "Bogus PM file!!");
106
+
107
   if (DEBUG) 
108
     fprintf(stderr,"%s: LoadPM() - loading a %dx%d %s pic, %d planes\n",
109
 	    cmd, w, h, (thePic.pm_form==PM_I) ? "PM_I" : "PM_C", 
110
@@ -135,6 +138,8 @@
111
     return( pmError(bname, "file read error") );
112
   }
113
 
114
+  if (thePic.pm_cmtsize+1 <= 0)
115
+    return pmError(bname, "Bogus PM file!!");
116
 
117
   /* alloc and read in comment, if any */
118
   if (thePic.pm_cmtsize>0) {
119
@@ -155,6 +160,9 @@
120
     int  *intptr;
121
     byte *pic24, *picptr;
122
 
123
+    if (w <= 0 || h <= 0 || w*h*3 <= 0)
124
+      return pmError(bname, "Bogus PM file!!");
125
+
126
     if ((pic24 = (byte *) malloc((size_t) w*h*3))==NULL) {
127
       if (thePic.pm_cmt) free(thePic.pm_cmt);
128
       return( pmError(bname, "unable to malloc 24-bit picture") );
129
@@ -189,6 +197,9 @@
130
 
131
   else if (thePic.pm_form == PM_C && thePic.pm_np>1) {
132
     byte *pic24, *picptr, *rptr, *gptr, *bptr;
133
+
134
+    if (w <= 0 || h <= 0 || w*h*3 <= 0)
135
+      return pmError(bname, "Bogus PM file!!");
136
 
137
     if ((pic24 = (byte *) malloc((size_t) w*h*3))==NULL) {
138
       if (thePic.pm_cmt) free(thePic.pm_cmt);

Return to bug 72382