]> granicus.if.org Git - sudo/commitdiff
Fix trimming of non-escaped trailing space in ldif_parse_attribute().
authorTodd C. Miller <Todd.Miller@sudo.ws>
Thu, 18 Oct 2018 20:29:33 +0000 (14:29 -0600)
committerTodd C. Miller <Todd.Miller@sudo.ws>
Thu, 18 Oct 2018 20:29:33 +0000 (14:29 -0600)
Found by PVS-Studio.

plugins/sudoers/parse_ldif.c

index 1beb82087cd491102078048394c5cdc761bce1c5..4e14efe5560ca32aa0ffff41521af8d09405a6da 100644 (file)
@@ -117,10 +117,11 @@ ldif_parse_attribute(char *str)
 
     ep = str + strlen(str);
     while (ep > str && ep[-1] == ' ') {
-       /* Don't trim ecaped trailing space if not base64. */
-       if (!encoded && ep != str && ep[-2] == '\\')
+       ep--;
+       /* Don't trim escaped trailing space if not base64. */
+       if (!encoded && ep != str && ep[-1] == '\\')
            break;
-       *--ep = '\0';
+       *ep = '\0';
     }
 
     attr = str;