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:36 -0500 |
| commit | 54243cefdd3ab8133ebe7d3d705f35ca1d0b59eb (patch) | |
| tree | 5ceed59890052f4f8970bbac9ac1800811d94106 | |
| parent | d301524772be3eef5fae1bcd5ca76fac69bb3b6e (diff) | |
[PATCH] tdfxfb: Fix buffer overrun
The pseudo_palette has room only for 16 entries, but tdfxfb_setcolreg may
attempt to write more.
Coverity Bug 557
Signed-off-by: Antonino Daplas <adaplas@pol.net>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
| -rw-r--r-- | drivers/video/tdfxfb.c | 42 |
1 files changed, 23 insertions, 19 deletions
diff --git a/drivers/video/tdfxfb.c b/drivers/video/tdfxfb.c index 3e7baf4c9fa8..5e5328d682db 100644 --- a/drivers/video/tdfxfb.c +++ b/drivers/video/tdfxfb.c | |||
| @@ -786,28 +786,32 @@ static int tdfxfb_setcolreg(unsigned regno, unsigned red, unsigned green, | |||
| 786 | if (regno >= info->cmap.len || regno > 255) return 1; | 786 | if (regno >= info->cmap.len || regno > 255) return 1; |
| 787 | 787 | ||
| 788 | switch (info->fix.visual) { | 788 | switch (info->fix.visual) { |
| 789 | case FB_VISUAL_PSEUDOCOLOR: | 789 | case FB_VISUAL_PSEUDOCOLOR: |
| 790 | rgbcol =(((u32)red & 0xff00) << 8) | | 790 | rgbcol =(((u32)red & 0xff00) << 8) | |
| 791 | (((u32)green & 0xff00) << 0) | | 791 | (((u32)green & 0xff00) << 0) | |
| 792 | (((u32)blue & 0xff00) >> 8); | 792 | (((u32)blue & 0xff00) >> 8); |
| 793 | do_setpalentry(par, regno, rgbcol); | 793 | do_setpalentry(par, regno, rgbcol); |
| 794 | break; | 794 | break; |
| 795 | /* Truecolor has no hardware color palettes. */ | 795 | /* Truecolor has no hardware color palettes. */ |
| 796 | case FB_VISUAL_TRUECOLOR: | 796 | case FB_VISUAL_TRUECOLOR: |
| 797 | if (regno < 16) { | ||
| 797 | rgbcol = (CNVT_TOHW( red, info->var.red.length) << | 798 | rgbcol = (CNVT_TOHW( red, info->var.red.length) << |
| 798 | info->var.red.offset) | | 799 | info->var.red.offset) | |
| 799 | (CNVT_TOHW( green, info->var.green.length) << | 800 | (CNVT_TOHW( green, info->var.green.length) << |
| 800 | info->var.green.offset) | | 801 | info->var.green.offset) | |
| 801 | (CNVT_TOHW( blue, info->var.blue.length) << | 802 | (CNVT_TOHW( blue, info->var.blue.length) << |
| 802 | info->var.blue.offset) | | 803 | info->var.blue.offset) | |
| 803 | (CNVT_TOHW( transp, info->var.transp.length) << | 804 | (CNVT_TOHW( transp, info->var.transp.length) << |
| 804 | info->var.transp.offset); | 805 | info->var.transp.offset); |
| 805 | par->palette[regno] = rgbcol; | 806 | par->palette[regno] = rgbcol; |
| 806 | break; | 807 | } |
| 807 | default: | 808 | |
| 808 | DPRINTK("bad depth %u\n", info->var.bits_per_pixel); | 809 | break; |
| 809 | break; | 810 | default: |
| 811 | DPRINTK("bad depth %u\n", info->var.bits_per_pixel); | ||
| 812 | break; | ||
| 810 | } | 813 | } |
| 814 | |||
| 811 | return 0; | 815 | return 0; |
| 812 | } | 816 | } |
| 813 | 817 | ||
