Skip to content

Commit 008ab3c

Browse files
Dan Carpentergregkh
authored andcommitted
speakup: Fix sizeof() vs ARRAY_SIZE() bug
The "buf" pointer is an array of u16 values. This code should be using ARRAY_SIZE() (which is 256) instead of sizeof() (which is 512), otherwise it can the still got out of bounds. Fixes: c8d2f34 ("speakup: Avoid crash on very long word") Cc: stable@vger.kernel.org Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org> Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org> Link: https://lore.kernel.org/r/d16f67d2-fd0a-4d45-adac-75ddd11001aa@moroto.mountain Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent dd5a440 commit 008ab3c

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

  • drivers/accessibility/speakup

drivers/accessibility/speakup/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ static u_long get_word(struct vc_data *vc)
574574
}
575575
attr_ch = get_char(vc, (u_short *)tmp_pos, &spk_attr);
576576
buf[cnt++] = attr_ch;
577-
while (tmpx < vc->vc_cols - 1 && cnt < sizeof(buf) - 1) {
577+
while (tmpx < vc->vc_cols - 1 && cnt < ARRAY_SIZE(buf) - 1) {
578578
tmp_pos += 2;
579579
tmpx++;
580580
ch = get_char(vc, (u_short *)tmp_pos, &temp);

0 commit comments

Comments
 (0)