Fix oob read in prefixline and oob write in r_cons_canvas_write

This commit is contained in:
Álvaro Felipe Melchor 2015-07-31 22:56:48 +02:00
parent 8b7d699303
commit 19c48e7edb

View File

@ -96,11 +96,13 @@ static int get_piece (const char *p, char *chr) {
}
static char *prefixline(RConsCanvas *c, int *left) {
int x;
int x, len;
char *p;
if (!c) return NULL;
if (strlen (c->b) < (c->y * c->w)) return NULL;
p = c->b + (c->y * c->w);
for (x = 0; p[x] && x<c->x; x++) {
len = strlen(p)-1;
for (x = 0; (p[x] && x<c->x) && x < len; x++) {
if (p[x] == '\n')
p[x] = ' ';
}