]> granicus.if.org Git - sudo/commitdiff
Support comments that start in the middle of a line
authorTodd C. Miller <Todd.Miller@courtesan.com>
Wed, 23 Nov 2005 23:57:10 +0000 (23:57 +0000)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Wed, 23 Nov 2005 23:57:10 +0000 (23:57 +0000)
ldap.c

diff --git a/ldap.c b/ldap.c
index dfafeccfbc252a232b91a84c2caa75f806296f1a..3f906e22354a52de24f3ac11f59ad4dc39ff5585 100644 (file)
--- 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)