Commit b2b183c2700d40210df51ff3ec9a2568ce9f5a43
1 parent
4dc822d7
do boundary check based on absolute value (Glauber Costa)
For backward operations, dstpitch and srcpitch can be negative. This leads BLTUNSAFE macro into an overflow, and as a result, it avoids performing operations that are perfectly valid. The visible effect that led to that patch was the gnome-panel bar in Fedora10. Before this patch, you could see garbage clobbering a big portion of the bar. After this patch, this garbage is gone. Signed-off-by: Glauber Costa <glommer@redhat.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5880 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
4 additions
and
2 deletions
hw/cirrus_vga.c
... | ... | @@ -221,15 +221,17 @@ |
221 | 221 | #define CIRRUS_HOOK_NOT_HANDLED 0 |
222 | 222 | #define CIRRUS_HOOK_HANDLED 1 |
223 | 223 | |
224 | +#define ABS(a) ((signed)(a) > 0 ? a : -a) | |
225 | + | |
224 | 226 | #define BLTUNSAFE(s) \ |
225 | 227 | ( \ |
226 | 228 | ( /* check dst is within bounds */ \ |
227 | - (s)->cirrus_blt_height * (s)->cirrus_blt_dstpitch \ | |
229 | + (s)->cirrus_blt_height * ABS((s)->cirrus_blt_dstpitch) \ | |
228 | 230 | + ((s)->cirrus_blt_dstaddr & (s)->cirrus_addr_mask) > \ |
229 | 231 | (s)->vram_size \ |
230 | 232 | ) || \ |
231 | 233 | ( /* check src is within bounds */ \ |
232 | - (s)->cirrus_blt_height * (s)->cirrus_blt_srcpitch \ | |
234 | + (s)->cirrus_blt_height * ABS((s)->cirrus_blt_srcpitch) \ | |
233 | 235 | + ((s)->cirrus_blt_srcaddr & (s)->cirrus_addr_mask) > \ |
234 | 236 | (s)->vram_size \ |
235 | 237 | ) \ | ... | ... |