From: Todd C. Miller Date: Wed, 23 Nov 2005 23:57:10 +0000 (+0000) Subject: Support comments that start in the middle of a line X-Git-Tag: SUDO_1_7_0~599 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=920c811687c2d0d3cdd0129b74e97c2b7b515884;p=sudo Support comments that start in the middle of a line --- diff --git a/ldap.c b/ldap.c index dfafeccfb..3f906e223 100644 --- a/ldap.c +++ b/ldap.c @@ -468,20 +468,19 @@ sudo_ldap_read_config() if ((f = fopen(_PATH_LDAP_CONF, "r")) == NULL) return(FALSE); while (fgets(buf, sizeof(buf), f)) { - c = buf; - if (*c == '#') - continue; /* ignore comment */ - if (*c == '\n') - continue; /* skip newline */ - if (!*c) - continue; /* incomplete last line */ - - /* skip whitespace before keyword */ - while (isspace((unsigned char) *c)) - c++; - keyword = c; + /* ignore text after comment character */ + if ((c = strchr(buf, '#')) != NULL) + *c = '\0'; + + /* skip leading whitespace */ + for (c = buf; isspace((unsigned char) *c); c++) + /* nothing */; + + if (*c == '\0' || *c == '\n') + continue; /* skip empty line */ /* properly terminate keyword string */ + keyword = c; while (*c && !isspace((unsigned char) *c)) c++; if (*c)