Windows: fix Freelance trailing dot enforcement

The cm_enforceTrailingDot() function failed if there was a
trailing dot followed by white space.

LICENSE MIT

Change-Id: Ib6a90420459a44b87995c44a5f58fcdcd5041c9f
Reviewed-on: http://gerrit.openafs.org/2588
Reviewed-by: Jeffrey Altman <jaltman@openafs.org>
Tested-by: Jeffrey Altman <jaltman@openafs.org>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
This commit is contained in:
Jeffrey Altman 2010-08-17 01:24:39 -04:00 committed by Derrick Brashear
parent fa1c0cfe5f
commit a81c323fbd

View File

@ -501,13 +501,21 @@ int cm_reInitLocalMountPoints() {
static int
cm_enforceTrailingDot(char * line, size_t cchLine, DWORD *pdwSize)
{
if (line[(*pdwSize)-1] == '\0' && line[(*pdwSize)-2] != '.') {
/* remove trailing whitespace */
/* trailing white space first. */
if (line[(*pdwSize)-1] == '\0') {
while (isspace(line[(*pdwSize)-2])) {
line[(*pdwSize)-2] = '\0';
(*pdwSize)--;
}
} else {
while (isspace(line[(*pdwSize)-1])) {
line[(*pdwSize)-1] = '\0';
(*pdwSize)--;
}
}
/* then enforce the trailing dot requirement */
if (line[(*pdwSize)-1] == '\0' && line[(*pdwSize)-2] != '.') {
if ((*pdwSize) >= cchLine) {
afsi_log("no room for trailing dot");
return 0;
@ -515,12 +523,6 @@ cm_enforceTrailingDot(char * line, size_t cchLine, DWORD *pdwSize)
line[(*pdwSize)-1] = '.';
line[(*pdwSize)] = '\0';
} else if (line[(*pdwSize)-1] != '\0' && line[(*pdwSize)-1] != '.') {
/* remove trailing whitespace */
while (isspace(line[(*pdwSize)-1])) {
line[(*pdwSize)-1] = '\0';
(*pdwSize)--;
}
if ((*pdwSize) >= cchLine) {
afsi_log("no room for trailing dot and nul");
return 0;
@ -528,12 +530,6 @@ cm_enforceTrailingDot(char * line, size_t cchLine, DWORD *pdwSize)
line[(*pdwSize)] = '.';
line[(*pdwSize)+1] = '\0';
} else if (line[(*pdwSize)-1] != '\0') {
/* remove trailing whitespace */
while (isspace(line[(*pdwSize)-1])) {
line[(*pdwSize)-1] = '\0';
(*pdwSize)--;
}
if ((*pdwSize) >= cchLine) {
afsi_log("no room for trailing nul");
return 0;