Subject: *important* FvwmPager bugfix

From: Ben Winslow <[email-masked]>
Date: Wed, 25 Aug 1999 14:21:43 -0400 (EDT)

Since CreateStretch*Pixmap uses an unsigned int for width and height, if it
gets passed a negative number (due to an application with broken window
hints), the highest bit is set, resulting in an insanely high number (eg.
4294967295), which causes FvwmPager to allocate huge amounts of memory,
enough to bring many systems to their knees..  Here's the fix:

Index: libs/Graphics.c
===================================================================
RCS file: /home/cvs/fvwm/fvwm/libs/Graphics.c,v
retrieving revision 1.18
diff -r1.18 Graphics.c
73,75c73,75
< Pixmap CreateStretchXPixmap(Display *dpy, Pixmap src, unsigned int src_width,
< 			    unsigned int src_height, unsigned int src_depth,
< 			    unsigned int dest_width, GC gc)
---
> Pixmap CreateStretchXPixmap(Display *dpy, Pixmap src, int src_width,
> 			    int src_height, int src_depth,
> 			    int dest_width, GC gc)
78c78,83
<   Pixmap pixmap = XCreatePixmap(dpy, src, dest_width, src_height, src_depth);
---
>   Pixmap pixmap;
>   
>   if (src_width < 0 || src_height < 0 || dest_width < 0)
>   	return None;
>   
>   pixmap = XCreatePixmap(dpy, src, dest_width, src_height, src_depth);
92,94c97,99
< Pixmap CreateStretchYPixmap(Display *dpy, Pixmap src, unsigned int src_width,
< 			    unsigned int src_height, unsigned int src_depth,
< 			    unsigned int dest_height, GC gc)
---
> Pixmap CreateStretchYPixmap(Display *dpy, Pixmap src, int src_width,
> 			    int src_height, int src_depth,
> 			    int dest_height, GC gc)
97c102,107
<   Pixmap pixmap = XCreatePixmap(dpy, src, src_width, dest_height, src_depth);
---
>   Pixmap pixmap;
> 
>   if (src_height < 0 || src_depth < 0 || dest_height < 0)
>   	return None;
>   
>   pixmap = XCreatePixmap(dpy, src, src_width, dest_height, src_depth);
111,113c121,123
< Pixmap CreateStretchPixmap(Display *dpy, Pixmap src, unsigned int src_width,
< 			    unsigned int src_height, unsigned int src_depth,
< 			    unsigned int dest_width, unsigned int dest_height,
---
> Pixmap CreateStretchPixmap(Display *dpy, Pixmap src, int src_width,
> 			    int src_height, int src_depth,
> 			    int dest_width, int dest_height,
117c127,132
<   Pixmap temp_pixmap = CreateStretchXPixmap(dpy, src, src_width, src_height,
---
>   Pixmap temp_pixmap;
>   
>   if (src_width < 0 || src_height < 0 || src_depth < 0 || dest_width < 0)
>   	return;
> 
>   temp_pixmap = CreateStretchXPixmap(dpy, src, src_width, src_height,
133,135c148,150
< Pixmap CreateTiledMaskPixmap(Display *dpy, Pixmap src, unsigned int src_width,
< 			     unsigned int src_height, unsigned int dest_width,
< 			     unsigned int dest_height, GC gc)
---
> Pixmap CreateTiledMaskPixmap(Display *dpy, Pixmap src, int src_width,
> 			     int src_height, int dest_width,
> 			     int dest_height, GC gc)
139c154,159
<   Pixmap pixmap = XCreatePixmap(dpy, src, dest_width, dest_height, 1);
---
>   Pixmap pixmap;
>   
>   if (src_width < 0 || src_height < 0 || dest_width < 0 || dest_height < 0)
>   	return None;
> 
>   pixmap = XCreatePixmap(dpy, src, dest_width, dest_height, 1);
539c559
< 			      int type, unsigned g_width, unsigned g_height,
---
> 			      int type, int g_width, int g_height,
543,544c563,564
< 			      unsigned int d_width,
< 			      unsigned int d_height)
---
> 			      int d_width,
> 			      int d_height)
554a575,577
> 
>   if (g_height < 0 || g_width < 0 || d_width < 0 || d_height < 0)
>   	return None;
Index: libs/fvwmlib.h
===================================================================
RCS file: /home/cvs/fvwm/fvwm/libs/fvwmlib.h,v
retrieving revision 1.52
diff -r1.52 fvwmlib.h
205,215c205,215
< Pixmap CreateStretchXPixmap(Display *dpy, Pixmap src, unsigned int src_width,
< 			    unsigned int src_height, unsigned int src_depth,
< 			    unsigned int dest_width, GC gc);
< 
< Pixmap CreateStretchYPixmap(Display *dpy, Pixmap src, unsigned int src_width,
< 			    unsigned int src_height, unsigned int src_depth,
< 			    unsigned int dest_height, GC gc);
< 
< Pixmap CreateStretchPixmap(Display *dpy, Pixmap src, unsigned int src_width,
< 			    unsigned int src_height, unsigned int src_depth,
< 			    unsigned int dest_width, unsigned int dest_height,
---
> Pixmap CreateStretchXPixmap(Display *dpy, Pixmap src, int src_width,
> 			    int src_height, int src_depth,
> 			    int dest_width, GC gc);
> 
> Pixmap CreateStretchYPixmap(Display *dpy, Pixmap src, int src_width,
> 			    int src_height, int src_depth,
> 			    int dest_height, GC gc);
> 
> Pixmap CreateStretchPixmap(Display *dpy, Pixmap src, int src_width,
> 			    int src_height, int src_depth,
> 			    int dest_width, int dest_height,
218,220c218,220
< Pixmap CreateTiledMaskPixmap(Display *dpy, Pixmap src, unsigned int src_width,
< 			     unsigned int src_height, unsigned int dest_width,
< 			     unsigned int dest_height, GC gc);
---
> Pixmap CreateTiledMaskPixmap(Display *dpy, Pixmap src, int src_width,
> 			     int src_height, int dest_width,
> 			     int dest_height, GC gc);
256c256
< 			      int type, unsigned g_width, unsigned g_height,
---
> 			      int type, int g_width, int g_height,
260,261c260,261
< 			      unsigned int d_width,
< 			      unsigned int d_height);
---
> 			      int d_width,
> 			      int d_height);

-- 
Ben Winslow / [email-masked] / |Rain| / freshmeat news squad

Knowledge is of no value unless you put it into practice.
- Heber J. Grant

--
Visit the official FVWM web page at <URL:http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm-workers" in the
body of a message to [email-masked].
To report problems, send mail to [email-masked]