a5f9360
diff -up sudo-1.8.11b4/plugins/sudoers/ldap.c.ldapconfpatch sudo-1.8.11b4/plugins/sudoers/ldap.c
a5f9360
--- sudo-1.8.11b4/plugins/sudoers/ldap.c.ldapconfpatch	2014-07-22 22:52:34.000000000 +0200
a5f9360
+++ sudo-1.8.11b4/plugins/sudoers/ldap.c	2014-09-15 11:22:11.122094452 +0200
a5f9360
@@ -1550,6 +1550,33 @@ sudo_check_krb5_ccname(const char *ccnam
a5f9360
 }
a5f9360
 #endif /* HAVE_LDAP_SASL_INTERACTIVE_BIND_S */
a5f9360
 
a5f9360
+/*
a5f9360
+ * Read a line of input, remove whole line comments and strip off leading
a5f9360
+ * and trailing spaces.  Returns static storage that is reused.
a5f9360
+ */
a5f9360
+static char *
a5f9360
+sudo_ldap_parseln(fp)
a5f9360
+    FILE *fp;
a5f9360
+{
a5f9360
+    size_t len;
a5f9360
+    char *cp = NULL;
a5f9360
+    static char buf[LINE_MAX];
a5f9360
+
a5f9360
+    if (fgets(buf, sizeof(buf), fp) != NULL) {
a5f9360
+	/* Remove comments */
a5f9360
+	if (*buf == '#')
a5f9360
+	    *buf = '\0';
a5f9360
+
a5f9360
+	/* Trim leading and trailing whitespace/newline */
a5f9360
+	len = strlen(buf);
a5f9360
+	while (len > 0 && isspace((unsigned char)buf[len - 1]))
a5f9360
+	    buf[--len] = '\0';
a5f9360
+	for (cp = buf; isblank(*cp); cp++)
a5f9360
+	    continue;
a5f9360
+    }
a5f9360
+    return(cp);
a5f9360
+}
a5f9360
+
a5f9360
 static bool
a5f9360
 sudo_ldap_read_config(void)
a5f9360
 {
a5f9360
@@ -1575,7 +1602,7 @@ sudo_ldap_read_config(void)
a5f9360
     if ((fp = fopen(path_ldap_conf, "r")) == NULL)
a5f9360
 	debug_return_bool(false);
a5f9360
 
a5f9360
-    while (sudo_parseln(&line, &linesize, NULL, fp) != -1) {
a5f9360
+    while ((line = sudo_ldap_parseln(fp)) != NULL) {
a5f9360
 	if (*line == '\0')
a5f9360
 	    continue;		/* skip empty line */
a5f9360
 
a5f9360
@@ -1595,7 +1622,6 @@ sudo_ldap_read_config(void)
a5f9360
 	if (!sudo_ldap_parse_keyword(keyword, value, ldap_conf_global))
a5f9360
 	    sudo_ldap_parse_keyword(keyword, value, ldap_conf_conn);
a5f9360
     }
a5f9360
-    free(line);
a5f9360
     fclose(fp);
a5f9360
 
a5f9360
     if (!ldap_conf.host)