|
|
6bbd11 |
autofs-5.1.0 - check amd lex buffer len before copy
|
|
|
6bbd11 |
|
|
|
6bbd11 |
From: Ian Kent <ikent@redhat.com>
|
|
|
6bbd11 |
|
|
|
6bbd11 |
Guard against lex to yacc communication buffer overflow.
|
|
|
6bbd11 |
---
|
|
|
6bbd11 |
CHANGELOG | 1 +
|
|
|
6bbd11 |
modules/amd_tok.l | 49 +++++++++++++++++++++++++++++++------------------
|
|
|
6bbd11 |
2 files changed, 32 insertions(+), 18 deletions(-)
|
|
|
6bbd11 |
|
|
|
6bbd11 |
--- autofs-5.0.7.orig/CHANGELOG
|
|
|
6bbd11 |
+++ autofs-5.0.7/CHANGELOG
|
|
|
6bbd11 |
@@ -138,6 +138,7 @@
|
|
|
6bbd11 |
- fix buffer size checks in get_network_proximity().
|
|
|
6bbd11 |
- fix leak in get_network_proximity().
|
|
|
6bbd11 |
- fix buffer size checks in merge_options().
|
|
|
6bbd11 |
+- check amd lex buffer len before copy.
|
|
|
6bbd11 |
|
|
|
6bbd11 |
25/07/2012 autofs-5.0.7
|
|
|
6bbd11 |
=======================
|
|
|
6bbd11 |
--- autofs-5.0.7.orig/modules/amd_tok.l
|
|
|
6bbd11 |
+++ autofs-5.0.7/modules/amd_tok.l
|
|
|
6bbd11 |
@@ -22,6 +22,7 @@
|
|
|
6bbd11 |
# undef ECHO
|
|
|
6bbd11 |
#endif
|
|
|
6bbd11 |
static void amd_echo(void); /* forward definition */
|
|
|
6bbd11 |
+static void amd_copy_buffer(void);
|
|
|
6bbd11 |
#define ECHO amd_echo()
|
|
|
6bbd11 |
int amd_wrap(void);
|
|
|
6bbd11 |
|
|
|
6bbd11 |
@@ -125,26 +126,26 @@ CUTSEP (\|\||\/)
|
|
|
6bbd11 |
|
|
|
6bbd11 |
{MAPOPT} {
|
|
|
6bbd11 |
BEGIN(MAPOPTVAL);
|
|
|
6bbd11 |
- strcpy(amd_lval.strtype, amd_text);
|
|
|
6bbd11 |
+ amd_copy_buffer();
|
|
|
6bbd11 |
return MAP_OPTION;
|
|
|
6bbd11 |
|
|
|
6bbd11 |
}
|
|
|
6bbd11 |
|
|
|
6bbd11 |
{FSOPTS} {
|
|
|
6bbd11 |
BEGIN(FSOPTVAL);
|
|
|
6bbd11 |
- strcpy(amd_lval.strtype, amd_text);
|
|
|
6bbd11 |
+ amd_copy_buffer();
|
|
|
6bbd11 |
return FS_OPTION;
|
|
|
6bbd11 |
}
|
|
|
6bbd11 |
|
|
|
6bbd11 |
{MNTOPT} {
|
|
|
6bbd11 |
BEGIN(MNTOPTVAL);
|
|
|
6bbd11 |
- strcpy(amd_lval.strtype, amd_text);
|
|
|
6bbd11 |
+ amd_copy_buffer();
|
|
|
6bbd11 |
return MNT_OPTION;
|
|
|
6bbd11 |
}
|
|
|
6bbd11 |
|
|
|
6bbd11 |
{SELOPT} {
|
|
|
6bbd11 |
BEGIN(SELOPTVAL);
|
|
|
6bbd11 |
- strcpy(amd_lval.strtype, amd_text);
|
|
|
6bbd11 |
+ amd_copy_buffer();
|
|
|
6bbd11 |
return SELECTOR;
|
|
|
6bbd11 |
}
|
|
|
6bbd11 |
|
|
|
6bbd11 |
@@ -152,13 +153,13 @@ CUTSEP (\|\||\/)
|
|
|
6bbd11 |
|
|
|
6bbd11 |
{SEL1ARG} {
|
|
|
6bbd11 |
BEGIN(SELARGVAL);
|
|
|
6bbd11 |
- strcpy(amd_lval.strtype, amd_text);
|
|
|
6bbd11 |
+ amd_copy_buffer();
|
|
|
6bbd11 |
return SELECTOR;
|
|
|
6bbd11 |
}
|
|
|
6bbd11 |
|
|
|
6bbd11 |
{SEL2ARG} {
|
|
|
6bbd11 |
BEGIN(SELARGVAL);
|
|
|
6bbd11 |
- strcpy(amd_lval.strtype, amd_text);
|
|
|
6bbd11 |
+ amd_copy_buffer();
|
|
|
6bbd11 |
return SELECTOR;
|
|
|
6bbd11 |
}
|
|
|
6bbd11 |
|
|
|
6bbd11 |
@@ -171,7 +172,7 @@ CUTSEP (\|\||\/)
|
|
|
6bbd11 |
#.* { return COMMENT; }
|
|
|
6bbd11 |
|
|
|
6bbd11 |
{OTHR} {
|
|
|
6bbd11 |
- strcpy(amd_lval.strtype, amd_text);
|
|
|
6bbd11 |
+ amd_copy_buffer();
|
|
|
6bbd11 |
return OTHER;
|
|
|
6bbd11 |
}
|
|
|
6bbd11 |
}
|
|
|
6bbd11 |
@@ -201,22 +202,22 @@ CUTSEP (\|\||\/)
|
|
|
6bbd11 |
":=" { return OPTION_ASSIGN; }
|
|
|
6bbd11 |
|
|
|
6bbd11 |
{FSTYPE} {
|
|
|
6bbd11 |
- strcpy(amd_lval.strtype, amd_text);
|
|
|
6bbd11 |
+ amd_copy_buffer();
|
|
|
6bbd11 |
return FS_TYPE;
|
|
|
6bbd11 |
}
|
|
|
6bbd11 |
|
|
|
6bbd11 |
{MAPTYPE} {
|
|
|
6bbd11 |
- strcpy(amd_lval.strtype, amd_text);
|
|
|
6bbd11 |
+ amd_copy_buffer();
|
|
|
6bbd11 |
return MAP_TYPE;
|
|
|
6bbd11 |
}
|
|
|
6bbd11 |
|
|
|
6bbd11 |
{CHEOPT} {
|
|
|
6bbd11 |
- strcpy(amd_lval.strtype, amd_text);
|
|
|
6bbd11 |
+ amd_copy_buffer();
|
|
|
6bbd11 |
return CACHE_OPTION;
|
|
|
6bbd11 |
}
|
|
|
6bbd11 |
|
|
|
6bbd11 |
{FOPT} {
|
|
|
6bbd11 |
- strcpy(amd_lval.strtype, amd_text);
|
|
|
6bbd11 |
+ amd_copy_buffer();
|
|
|
6bbd11 |
return FS_OPT_VALUE;
|
|
|
6bbd11 |
}
|
|
|
6bbd11 |
}
|
|
|
6bbd11 |
@@ -246,7 +247,7 @@ CUTSEP (\|\||\/)
|
|
|
6bbd11 |
":=" { return OPTION_ASSIGN; }
|
|
|
6bbd11 |
|
|
|
6bbd11 |
{FOPT} {
|
|
|
6bbd11 |
- strcpy(amd_lval.strtype, amd_text);
|
|
|
6bbd11 |
+ amd_copy_buffer();
|
|
|
6bbd11 |
return FS_OPT_VALUE;
|
|
|
6bbd11 |
}
|
|
|
6bbd11 |
}
|
|
|
6bbd11 |
@@ -278,7 +279,7 @@ CUTSEP (\|\||\/)
|
|
|
6bbd11 |
"," { return COMMA; }
|
|
|
6bbd11 |
|
|
|
6bbd11 |
{OPTS} {
|
|
|
6bbd11 |
- strcpy(amd_lval.strtype, amd_text);
|
|
|
6bbd11 |
+ amd_copy_buffer();
|
|
|
6bbd11 |
return OPTION;
|
|
|
6bbd11 |
}
|
|
|
6bbd11 |
}
|
|
|
6bbd11 |
@@ -310,7 +311,7 @@ CUTSEP (\|\||\/)
|
|
|
6bbd11 |
"!=" { return NOT_EQUAL; }
|
|
|
6bbd11 |
|
|
|
6bbd11 |
{SOPT} {
|
|
|
6bbd11 |
- strcpy(amd_lval.strtype, amd_text);
|
|
|
6bbd11 |
+ amd_copy_buffer();
|
|
|
6bbd11 |
return SELECTOR_VALUE;
|
|
|
6bbd11 |
}
|
|
|
6bbd11 |
}
|
|
|
6bbd11 |
@@ -335,24 +336,24 @@ CUTSEP (\|\||\/)
|
|
|
6bbd11 |
"(" { return LBRACKET; }
|
|
|
6bbd11 |
|
|
|
6bbd11 |
{NOPT} {
|
|
|
6bbd11 |
- strcpy(amd_lval.strtype, amd_text);
|
|
|
6bbd11 |
+ amd_copy_buffer();
|
|
|
6bbd11 |
return SEL_ARG_VALUE;
|
|
|
6bbd11 |
}
|
|
|
6bbd11 |
|
|
|
6bbd11 |
{SOPT}/"," {
|
|
|
6bbd11 |
- strcpy(amd_lval.strtype, amd_text);
|
|
|
6bbd11 |
+ amd_copy_buffer();
|
|
|
6bbd11 |
return SEL_ARG_VALUE;
|
|
|
6bbd11 |
}
|
|
|
6bbd11 |
|
|
|
6bbd11 |
"," { return COMMA; }
|
|
|
6bbd11 |
|
|
|
6bbd11 |
{SOPT} {
|
|
|
6bbd11 |
- strcpy(amd_lval.strtype, amd_text);
|
|
|
6bbd11 |
+ amd_copy_buffer();
|
|
|
6bbd11 |
return SEL_ARG_VALUE;
|
|
|
6bbd11 |
}
|
|
|
6bbd11 |
|
|
|
6bbd11 |
{FOPT} {
|
|
|
6bbd11 |
- strcpy(amd_lval.strtype, amd_text);
|
|
|
6bbd11 |
+ amd_copy_buffer();
|
|
|
6bbd11 |
return SEL_ARG_VALUE;
|
|
|
6bbd11 |
}
|
|
|
6bbd11 |
|
|
|
6bbd11 |
@@ -368,6 +369,18 @@ int amd_wrap(void)
|
|
|
6bbd11 |
return 1;
|
|
|
6bbd11 |
}
|
|
|
6bbd11 |
|
|
|
6bbd11 |
+static void amd_copy_buffer(void)
|
|
|
6bbd11 |
+{
|
|
|
6bbd11 |
+ if (amd_leng < 2048)
|
|
|
6bbd11 |
+ strcpy(amd_lval.strtype, amd_text);
|
|
|
6bbd11 |
+ else {
|
|
|
6bbd11 |
+ strncpy(amd_lval.strtype, amd_text, 2047);
|
|
|
6bbd11 |
+ amd_lval.strtype[2047] = '\0';
|
|
|
6bbd11 |
+ logmsg("warning: truncated option near %s\n",
|
|
|
6bbd11 |
+ &amd_lval.strtype[2030]);
|
|
|
6bbd11 |
+ }
|
|
|
6bbd11 |
+}
|
|
|
6bbd11 |
+
|
|
|
6bbd11 |
static void amd_echo(void)
|
|
|
6bbd11 |
{
|
|
|
6bbd11 |
logmsg("%s\n", amd_text);
|