Fix some buffer overflow

This commit is contained in:
jvoisin 2014-08-18 14:22:18 +02:00
parent cd9fd5ce29
commit 359846b0d1
4 changed files with 4 additions and 4 deletions

View File

@ -274,7 +274,7 @@ static int use_stdin () {
static char buf[STDIN_BUFFER_SIZE];
int l, sflag = (flags & 5);
for (l=0; l>=0; l++) {
int n = read (0, buf+l, sizeof (buf)-l);
int n = read (0, buf+l, sizeof (buf)-l-1);
if (n<1) break;
l+= n;
if (buf[l-1]==0) {

View File

@ -87,7 +87,7 @@ R_API RList *r_core_asm_strsearch(RCore *core, const char *input, ut64 from, ut6
return NULL;
}
tokens[0] = NULL;
for (tokcount=0; tokcount<sizeof (tokens)-1; tokcount++) {
for (tokcount=0; tokcount<(sizeof (tokens) / sizeof (char*)) - 1; tokcount++) {
tok = strtok (tokcount? NULL: ptr, ",");
if (tok == NULL)
break;

View File

@ -363,7 +363,7 @@ static int autocomplete(RLine *line) {
break;
}
}
tmp_argv[i] = NULL;
tmp_argv[i>255?255:i] = NULL;
line->completion.argc = i;
line->completion.argv = tmp_argv;
} else

View File

@ -1213,7 +1213,7 @@ static void handle_print_indent (RCore *core, RDisasmState *ds) {
char indent[128];
int num = ds->indent_level;
if (num<0) num = 0;
if (num>sizeof (indent))
if (num>=sizeof (indent))
num = sizeof(indent)-1;
memset (indent, ' ', num);
indent[num] = 0;