ALSA: Write outside array bounds
PATCH 1/1 ALSA: Write outside array bounds
e->sad[] is declared with size ELD_MAX_SAD (16), but the guard allows the range 0-31
---
Found with Parfait, http://research.sun.com/projects/parfait/
sound/pci/hda/hda_eld.c +1 -1
@@ -539,7 +539,7 @@ static void hdmi_write_eld_info(struct snd_info_entry *entry, sname++; n =10 * n + name[4 ] -'0' ; } -if (n <0 || n >31 )/* double the CEA limit */ +if (n <0 || n >ELD_MAX_SAD )continue ;if (!strcmp (sname,"_coding_type" )) e->sad[n].format = val;
PATCH v2 1/1 hda: fix out-of-bound hdmi_eld.sad[] write
Quoted 2 lines · Roel Kluin
e->sad[] is declared with size
ELD_MAX_SAD(16), but the guard allows the range 0-31
Good catch, thank you, Roel!
Minor fix: '>=' should be used in this line:
Review
Quoted 1 line
(quoted diff) +1
-0+ if (n < 0 || n > ELD_MAX_SAD)
So I'd suggest this updated patch.
Thanks,
Fengguang
---
hda: fix out-of-bound hdmi_eld.sad[] write
From: Roel Kluin <[email protected]>
e->sad[] is declared with size ELD_MAX_SAD=16, but the guard allows range 0-31.
--- sound/pci/hda/hda_eld.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/pci/hda/hda_eld.c +2 -2
@@ -508,7 +508,7 @@ static void hdmi_write_eld_info(struct schar name[64 ];char *sname;long long val; -int n; +unsigned int n;while (!snd_info_get_line (buffer, line,sizeof (line))) {if (sscanf (line,"%s %llx" , name, &val) !=2 )
@@ -539,7 +539,7 @@ static void hdmi_write_eld_info(struct s sname++; n =10 * n + name[4 ] -'0' ; } -if (n <0 || n >31 )/* double the CEA limit */ +if (n >=ELD_MAX_SAD )continue ;if (!strcmp (sname,"_coding_type" )) e->sad[n].format = val;
Re: [PATCH v2] hda: fix out-of-bound hdmi_eld.sad[] write
At Wed, 29 Jul 2009 19:31:14 +0800,
Quoted 5 lines · Wu Fengguang
Quoted 2 lines · Roel Kluin
e->sad[] is declared with size
ELD_MAX_SAD(16), but the guard allows the range 0-31
Quoted 7 lines
Good catch, thank you, Roel!
Minor fix: '>=' should be used in this line:
Review
Quoted 1 line
(quoted diff) +1
-0+ if (n < 0 || n > ELD_MAX_SAD)So I'd suggest this updated patch.
Applied the updated one now. Thanks.
Takashi
Quoted 37 lines
Thanks,
Fengguang
---
hda: fix out-of-bound hdmi_eld.sad[] writeFrom: Roel Kluin <[email protected]>
e->sad[] is declared with size ELD_MAX_SAD=16, but the guard allows range 0-31.
Signed-off-by Roel Kluin <[email protected]>Signed-off-by Wu Fengguang <[email protected]>--- sound/pci/hda/hda_eld.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)sound/pci/hda/hda_eld.c +2
-2@@ -508,7 +508,7 @@ static void hdmi_write_eld_info(struct schar name[64 ];char *sname;long long val; -int n; +unsigned int n;while (!snd_info_get_line (buffer, line,sizeof (line))) {if (sscanf (line,"%s %llx" , name, &val) !=2 )@@ -539,7 +539,7 @@ static void hdmi_write_eld_info(struct s sname++; n =10 * n + name[4 ] -'0' ; } -if (n <0 || n >31 )/* double the CEA limit */ +if (n >=ELD_MAX_SAD )continue ;if (!strcmp (sname,"_coding_type" )) e->sad[n].format = val;
Quoted 6 lines · Roel Kluin
e->sad[] is declared with size
ELD_MAX_SAD(16), but the guard allows the range 0-31Signed-off-by Roel Kluin <[email protected]>---
Found with Parfait, http://research.sun.com/projects/parfait/
I've been looking for this tool to evaluate; is it available publically, or do you have 'privilaged access'?
Thanks
Alan