diff options
author | Antonino A. Daplas <adaplas@gmail.com> | 2006-03-11 06:27:26 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-03-11 12:19:35 -0500 |
commit | d301524772be3eef5fae1bcd5ca76fac69bb3b6e (patch) | |
tree | d2d26317432a5726a7aa6192d510247990dfd7c5 /drivers/video | |
parent | 8d57f2210e72e0168734bd1503b9e52a71f53d65 (diff) |
[PATCH] intelfb: Fix buffer overrun
The pseudo_palette has room only for 16 entries, but intelfb_setcolreg will
attempt to write more.
Coverity Bug 558
Signed-off-by: Antonino Daplas <adaplas@pol.net>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/video')
-rw-r--r-- | drivers/video/intelfb/intelfbdrv.c | 50 |
1 files changed, 26 insertions, 24 deletions
diff --git a/drivers/video/intelfb/intelfbdrv.c b/drivers/video/intelfb/intelfbdrv.c index 6b8bd3cdf9c0..995b47c165a7 100644 --- a/drivers/video/intelfb/intelfbdrv.c +++ b/drivers/video/intelfb/intelfbdrv.c | |||
@@ -1333,33 +1333,35 @@ intelfb_setcolreg(unsigned regno, unsigned red, unsigned green, | |||
1333 | if (regno > 255) | 1333 | if (regno > 255) |
1334 | return 1; | 1334 | return 1; |
1335 | 1335 | ||
1336 | switch (dinfo->depth) { | 1336 | if (dinfo->depth == 8) { |
1337 | case 8: | 1337 | red >>= 8; |
1338 | { | 1338 | green >>= 8; |
1339 | red >>= 8; | 1339 | blue >>= 8; |
1340 | green >>= 8; | 1340 | |
1341 | blue >>= 8; | 1341 | intelfbhw_setcolreg(dinfo, regno, red, green, blue, |
1342 | transp); | ||
1343 | } | ||
1342 | 1344 | ||
1343 | intelfbhw_setcolreg(dinfo, regno, red, green, blue, | 1345 | if (regno < 16) { |
1344 | transp); | 1346 | switch (dinfo->depth) { |
1347 | case 15: | ||
1348 | dinfo->pseudo_palette[regno] = ((red & 0xf800) >> 1) | | ||
1349 | ((green & 0xf800) >> 6) | | ||
1350 | ((blue & 0xf800) >> 11); | ||
1351 | break; | ||
1352 | case 16: | ||
1353 | dinfo->pseudo_palette[regno] = (red & 0xf800) | | ||
1354 | ((green & 0xfc00) >> 5) | | ||
1355 | ((blue & 0xf800) >> 11); | ||
1356 | break; | ||
1357 | case 24: | ||
1358 | dinfo->pseudo_palette[regno] = ((red & 0xff00) << 8) | | ||
1359 | (green & 0xff00) | | ||
1360 | ((blue & 0xff00) >> 8); | ||
1361 | break; | ||
1345 | } | 1362 | } |
1346 | break; | ||
1347 | case 15: | ||
1348 | dinfo->pseudo_palette[regno] = ((red & 0xf800) >> 1) | | ||
1349 | ((green & 0xf800) >> 6) | | ||
1350 | ((blue & 0xf800) >> 11); | ||
1351 | break; | ||
1352 | case 16: | ||
1353 | dinfo->pseudo_palette[regno] = (red & 0xf800) | | ||
1354 | ((green & 0xfc00) >> 5) | | ||
1355 | ((blue & 0xf800) >> 11); | ||
1356 | break; | ||
1357 | case 24: | ||
1358 | dinfo->pseudo_palette[regno] = ((red & 0xff00) << 8) | | ||
1359 | (green & 0xff00) | | ||
1360 | ((blue & 0xff00) >> 8); | ||
1361 | break; | ||
1362 | } | 1363 | } |
1364 | |||
1363 | return 0; | 1365 | return 0; |
1364 | } | 1366 | } |
1365 | 1367 | ||