Skip to content

Commit

Permalink
kgdbts: Read buffer overflow
Browse files Browse the repository at this point in the history
Prevent write to put_buf[BUFMAX] in kgdb test suite.

If put_buf_cnt was BUFMAX - 1 at the earlier test,
`\0' is written to put_buf[BUFMAX].

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
  • Loading branch information
Roel Kluin authored and Jason Wessel committed Dec 11, 2009
1 parent 84667d4 commit b4f1b67
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions drivers/misc/kgdbts.c
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,12 @@ static int run_simple_test(int is_get_char, int chr)

/* End of packet == #XX so look for the '#' */
if (put_buf_cnt > 3 && put_buf[put_buf_cnt - 3] == '#') {
if (put_buf_cnt >= BUFMAX) {
eprintk("kgdbts: ERROR: put buffer overflow on"
" '%s' line %i\n", ts.name, ts.idx);
put_buf_cnt = 0;
return 0;
}
put_buf[put_buf_cnt] = '\0';
v2printk("put%i: %s\n", ts.idx, put_buf);
/* Trigger check here */
Expand Down

0 comments on commit b4f1b67

Please sign in to comment.