nfsmount: Fixed parsing error in the nfsmount.conf code.
Subsystems (2)
PATCH 1/1 nfsmount: Fixed parsing error in the nfsmount.conf code.
When the options where prefixed with spaces (instead of tabs) the second option in the list was missed to so a miscalculation the the nfsmount.conf parsing code.
Signed-off-by Steve Dickson <[email protected]>
--- support/nfs/conffile.c | 19 ++++++------------- 1 files changed, 6 insertions(+), 13 deletions(-)
support/nfs/conffile.c +6 -13
@@ -211,7 +211,7 @@ static void conf_parse_line(int trans, char *line, size_t sz) { char *val, *ptr; -size_t i; +size_t i, valsize;size_t j;static char *section =0 ;static char *arg =0 ;
@@ -298,23 +298,16 @@ conf_parse_line(int trans, char *line, size_t sz) } line[strcspn (line," \t=" )] ='\0' ; val = line + i +1 +strspn (line + i +1 ," \t" ); + valsize =0 ; +while (val[valsize++]); -/* Skip trailing comments, if any */ -for (j =0 ; j < sz - (val - line); j++) { -if (val[j] =='#' || val[j] ==';' ) { +/* Skip trailing spaces and comments */ +for (j =0 ; j < valsize; j++) { +if (val[j] =='#' || val[j] ==';' ||isspace (val[j])) { val[j] ='\0' ;break ; } } - -/* Skip trailing whitespace, if any */ -for (j--; j >0 ; j--) { -if (isspace (val[j])) - val[j] ='\0' ; -else -break ; - } -/* XXX Perhaps should we not ignore errors? */ conf_set (trans, section, arg, line, val,0 ,0 );return ;
Signature · 1 line
1.7.7.5
Quoted 5 lines · Steve Dickson
When the options where prefixed with spaces (instead of tabs) the second option in the list was missed to so a miscalculation the the nfsmount.conf parsing code.
Signed-off-by Steve Dickson <[email protected]>
Committed....
steved.
Quoted 46 lines
--- support/nfs/conffile.c | 19 ++++++------------- 1 files changed, 6 insertions(+), 13 deletions(-)support/nfs/conffile.c +6
-13@@ -211,7 +211,7 @@ static void conf_parse_line(int trans, char *line, size_t sz) { char *val, *ptr; -size_t i; +size_t i, valsize;size_t j;static char *section =0 ;static char *arg =0 ;@@ -298,23 +298,16 @@ conf_parse_line(int trans, char *line, size_t sz) } line[strcspn (line," \t=" )] ='\0' ; val = line + i +1 +strspn (line + i +1 ," \t" ); + valsize =0 ; +while (val[valsize++]); -/* Skip trailing comments, if any */ -for (j =0 ; j < sz - (val - line); j++) { -if (val[j] =='#' || val[j] ==';' ) { +/* Skip trailing spaces and comments */ +for (j =0 ; j < valsize; j++) { +if (val[j] =='#' || val[j] ==';' ||isspace (val[j])) { val[j] ='\0' ;break ; } } - -/* Skip trailing whitespace, if any */ -for (j--; j >0 ; j--) { -if (isspace (val[j])) - val[j] ='\0' ; -else -break ; - } -/* XXX Perhaps should we not ignore errors? */ conf_set (trans, section, arg, line, val,0 ,0 );return ;