* user.c (extract_line): Add a new parameter (size of the
output buffer) to prevent buffer overflow.
Этот коммит содержится в:
родитель
d1943ab8cf
Коммит
50dda0fcb3
@ -1,6 +1,8 @@
|
|||||||
2004-03-07 Andrew V. Samoilov <sav@bcs.zp.ua>
|
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>
|
2004-03-05 Pavel Roskin <proski@gnu.org>
|
||||||
|
|
||||||
@ -1489,7 +1491,7 @@
|
|||||||
unused defines.
|
unused defines.
|
||||||
* dlg.c: Adjust declarations for match.
|
* 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.
|
* wtools.c (quick_callback): Allocate widget table dynamically.
|
||||||
|
|
||||||
* dlg.c (widget_redraw): Remove.
|
* dlg.c (widget_redraw): Remove.
|
||||||
|
18
src/user.c
18
src/user.c
@ -299,13 +299,15 @@ check_patterns (char *p)
|
|||||||
|
|
||||||
/* Copies a whitespace separated argument from p to arg. Returns the
|
/* Copies a whitespace separated argument from p to arg. Returns the
|
||||||
point after argument. */
|
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'))
|
while (*p && (*p == ' ' || *p == '\t' || *p == '\n'))
|
||||||
p++;
|
p++;
|
||||||
/* support quote space .mnu */
|
/* 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++;
|
*arg++ = *p++;
|
||||||
|
size--;
|
||||||
|
}
|
||||||
*arg = 0;
|
*arg = 0;
|
||||||
if (!*p || *p == '\n')
|
if (!*p || *p == '\n')
|
||||||
p --;
|
p --;
|
||||||
@ -388,29 +390,29 @@ static char *test_condition (WEdit *edit_widget, char *p, int *condition)
|
|||||||
p--;
|
p--;
|
||||||
break;
|
break;
|
||||||
case 'f': /* file name pattern */
|
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);
|
*condition = panel && regexp_match (arg, panel->dir.list [panel->selected].fname, match_file);
|
||||||
break;
|
break;
|
||||||
case 'y': /* syntax pattern */
|
case 'y': /* syntax pattern */
|
||||||
if (edit_widget && edit_widget->syntax_type) {
|
if (edit_widget && edit_widget->syntax_type) {
|
||||||
p = extract_arg (p, arg);
|
p = extract_arg (p, arg, sizeof (arg));
|
||||||
*condition = panel &&
|
*condition = panel &&
|
||||||
regexp_match (arg, edit_widget->syntax_type, match_normal);
|
regexp_match (arg, edit_widget->syntax_type, match_normal);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'd':
|
case 'd':
|
||||||
p = extract_arg (p, arg);
|
p = extract_arg (p, arg, sizeof (arg));
|
||||||
*condition = panel && regexp_match (arg, panel->cwd, match_file);
|
*condition = panel && regexp_match (arg, panel->cwd, match_file);
|
||||||
break;
|
break;
|
||||||
case 't':
|
case 't':
|
||||||
p = extract_arg (p, arg);
|
p = extract_arg (p, arg, sizeof (arg));
|
||||||
*condition = panel && test_type (panel, arg);
|
*condition = panel && test_type (panel, arg);
|
||||||
break;
|
break;
|
||||||
case 'x': /* executable */
|
case 'x': /* executable */
|
||||||
{
|
{
|
||||||
struct stat status;
|
struct stat status;
|
||||||
|
|
||||||
p = extract_arg (p, arg);
|
p = extract_arg (p, arg, sizeof (arg));
|
||||||
if (stat (arg, &status) == 0)
|
if (stat (arg, &status) == 0)
|
||||||
*condition = is_exe (status.st_mode);
|
*condition = is_exe (status.st_mode);
|
||||||
else
|
else
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user