mirror of
https://github.com/radareorg/radare2.git
synced 2025-01-22 22:06:50 +00:00
Fix index out of bounds in r_cons_grep
This commit is contained in:
parent
9a1a2fc981
commit
ca624cd8cd
@ -6,9 +6,12 @@
|
||||
R_API void r_cons_grep(const char *str) {
|
||||
int len;
|
||||
RCons *cons;
|
||||
char buf[1024];
|
||||
char buf[4096];
|
||||
char *ptr, *optr, *ptr2, *ptr3;
|
||||
|
||||
if (!str || !*str)
|
||||
return;
|
||||
|
||||
cons = r_cons_singleton ();
|
||||
cons->grep.str = NULL;
|
||||
cons->grep.neg = 0;
|
||||
@ -20,9 +23,6 @@ R_API void r_cons_grep(const char *str) {
|
||||
cons->grep.line = -1;
|
||||
cons->grep.counter = cons->grep.neg = 0;
|
||||
|
||||
if (str == NULL || !*str)
|
||||
return;
|
||||
|
||||
if (*str == '^') { // neg
|
||||
cons->grep.begin = 1;
|
||||
str++;
|
||||
@ -36,9 +36,10 @@ R_API void r_cons_grep(const char *str) {
|
||||
str++;
|
||||
}
|
||||
len = strlen (str)-1;
|
||||
if (str[len] == '?') {
|
||||
if (len>0 && str[len] == '?') {
|
||||
cons->grep.counter = 1;
|
||||
strncpy (buf, str, len);
|
||||
strncpy (buf, str, R_MIN (len, sizeof (buf)-1));
|
||||
buf[len]=0;
|
||||
len--;
|
||||
} else strncpy (buf, str, sizeof (buf)-1);
|
||||
|
||||
|
@ -725,8 +725,7 @@ static int r_core_cmd_subst_i(RCore *core, char *cmd) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = r_cmd_call (core->cmd, r_str_trim_head (cmd));
|
||||
return ret;
|
||||
return cmd? r_cmd_call (core->cmd, r_str_trim_head (cmd)): R_FALSE;
|
||||
}
|
||||
|
||||
R_API int r_core_cmd_foreach(RCore *core, const char *cmd, char *each) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user