* user.c (extract_line): Add a new parameter (size of the

output buffer) to prevent buffer overflow.
This commit is contained in:
Andrew V. Samoilov 2004-03-07 06:24:14 +00:00
parent d1943ab8cf
commit 50dda0fcb3
2 changed files with 14 additions and 10 deletions

View File

@ -1,6 +1,8 @@
2004-03-07 Andrew V. Samoilov <sav@bcs.zp.ua>
* achown.c (init_chown_advanced) [ENABLE_NLS]: i18n fix.
* achown.c (init_chown_advanced) [ENABLE_NLS]: i18n fix.
* user.c (extract_line): Add a new parameter (size of the
output buffer) to prevent buffer overflow.
2004-03-05 Pavel Roskin <proski@gnu.org>
@ -1489,7 +1491,7 @@
unused defines.
* dlg.c: Adjust declarations for match.
* wtools.h: Eliminate the_widget filed in QuickWidget.
* wtools.h: Eliminate the_widget field in QuickWidget.
* wtools.c (quick_callback): Allocate widget table dynamically.
* dlg.c (widget_redraw): Remove.

View File

@ -299,13 +299,15 @@ check_patterns (char *p)
/* Copies a whitespace separated argument from p to arg. Returns the
point after argument. */
static char *extract_arg (char *p, char *arg)
static char *extract_arg (char *p, char *arg, int size)
{
while (*p && (*p == ' ' || *p == '\t' || *p == '\n'))
p++;
/* support quote space .mnu */
while (*p && (*p != ' ' || *(p-1) == '\\') && *p != '\t' && *p != '\n')
while (size > 1 && *p && (*p != ' ' || *(p-1) == '\\') && *p != '\t' && *p != '\n') {
*arg++ = *p++;
size--;
}
*arg = 0;
if (!*p || *p == '\n')
p --;
@ -388,29 +390,29 @@ static char *test_condition (WEdit *edit_widget, char *p, int *condition)
p--;
break;
case 'f': /* file name pattern */
p = extract_arg (p, arg);
p = extract_arg (p, arg, sizeof (arg));
*condition = panel && regexp_match (arg, panel->dir.list [panel->selected].fname, match_file);
break;
case 'y': /* syntax pattern */
if (edit_widget && edit_widget->syntax_type) {
p = extract_arg (p, arg);
p = extract_arg (p, arg, sizeof (arg));
*condition = panel &&
regexp_match (arg, edit_widget->syntax_type, match_normal);
}
break;
break;
case 'd':
p = extract_arg (p, arg);
p = extract_arg (p, arg, sizeof (arg));
*condition = panel && regexp_match (arg, panel->cwd, match_file);
break;
case 't':
p = extract_arg (p, arg);
p = extract_arg (p, arg, sizeof (arg));
*condition = panel && test_type (panel, arg);
break;
case 'x': /* executable */
{
struct stat status;
p = extract_arg (p, arg);
p = extract_arg (p, arg, sizeof (arg));
if (stat (arg, &status) == 0)
*condition = is_exe (status.st_mode);
else