mirror of
https://github.com/sudo-project/sudo.git
synced 2025-09-04 00:05:11 +00:00
In fill_cmnd(), collapse any escaped sudo-specific characters.
Allows character classes to be used in pathnames.
This commit is contained in:
22
toke.c
22
toke.c
@@ -3111,21 +3111,33 @@ append(src, len)
|
|||||||
return(_fill(src, len, olen));
|
return(_fill(src, len, olen));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define SPECIAL(c) \
|
||||||
|
((c) == ',' || (c) == ':' || (c) == '=' || (c) == ' ' || (c) == '\t' || (c) == '#')
|
||||||
|
|
||||||
static int
|
static int
|
||||||
fill_cmnd(s, len)
|
fill_cmnd(src, len)
|
||||||
char *s;
|
char *src;
|
||||||
int len;
|
int len;
|
||||||
{
|
{
|
||||||
|
char *dst;
|
||||||
|
int i;
|
||||||
|
|
||||||
arg_len = arg_size = 0;
|
arg_len = arg_size = 0;
|
||||||
|
|
||||||
yylval.command.cmnd = (char *) malloc(++len);
|
dst = yylval.command.cmnd = (char *) malloc(++len);
|
||||||
if (yylval.command.cmnd == NULL) {
|
if (yylval.command.cmnd == NULL) {
|
||||||
yyerror("unable to allocate memory");
|
yyerror("unable to allocate memory");
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* copy the string and NULL-terminate it (escapes handled by fnmatch) */
|
/* Copy the string and collapse any escaped sudo-specific characters. */
|
||||||
(void) strlcpy(yylval.command.cmnd, s, len);
|
for (i = 0; i < len; i++) {
|
||||||
|
if (src[i] == '\\' && i != len - 1 && SPECIAL(src[i + 1]))
|
||||||
|
*dst++ = src[++i];
|
||||||
|
else
|
||||||
|
*dst++ = src[i];
|
||||||
|
}
|
||||||
|
*dst = '\0';
|
||||||
|
|
||||||
yylval.command.args = NULL;
|
yylval.command.args = NULL;
|
||||||
return(TRUE);
|
return(TRUE);
|
||||||
|
22
toke.l
22
toke.l
@@ -530,21 +530,33 @@ append(src, len)
|
|||||||
return(_fill(src, len, olen));
|
return(_fill(src, len, olen));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define SPECIAL(c) \
|
||||||
|
((c) == ',' || (c) == ':' || (c) == '=' || (c) == ' ' || (c) == '\t' || (c) == '#')
|
||||||
|
|
||||||
static int
|
static int
|
||||||
fill_cmnd(s, len)
|
fill_cmnd(src, len)
|
||||||
char *s;
|
char *src;
|
||||||
int len;
|
int len;
|
||||||
{
|
{
|
||||||
|
char *dst;
|
||||||
|
int i;
|
||||||
|
|
||||||
arg_len = arg_size = 0;
|
arg_len = arg_size = 0;
|
||||||
|
|
||||||
yylval.command.cmnd = (char *) malloc(++len);
|
dst = yylval.command.cmnd = (char *) malloc(++len);
|
||||||
if (yylval.command.cmnd == NULL) {
|
if (yylval.command.cmnd == NULL) {
|
||||||
yyerror("unable to allocate memory");
|
yyerror("unable to allocate memory");
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* copy the string and NULL-terminate it (escapes handled by fnmatch) */
|
/* Copy the string and collapse any escaped sudo-specific characters. */
|
||||||
(void) strlcpy(yylval.command.cmnd, s, len);
|
for (i = 0; i < len; i++) {
|
||||||
|
if (src[i] == '\\' && i != len - 1 && SPECIAL(src[i + 1]))
|
||||||
|
*dst++ = src[++i];
|
||||||
|
else
|
||||||
|
*dst++ = src[i];
|
||||||
|
}
|
||||||
|
*dst = '\0';
|
||||||
|
|
||||||
yylval.command.args = NULL;
|
yylval.command.args = NULL;
|
||||||
return(TRUE);
|
return(TRUE);
|
||||||
|
Reference in New Issue
Block a user