From 2ff8f8601b8f348ee932aa6b65756d0723dfa9cb Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Thu, 18 Oct 2018 14:29:33 -0600 Subject: [PATCH] Fix trimming of non-escaped trailing space in ldif_parse_attribute(). Found by PVS-Studio. --- plugins/sudoers/parse_ldif.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/plugins/sudoers/parse_ldif.c b/plugins/sudoers/parse_ldif.c index 1beb82087..4e14efe55 100644 --- a/plugins/sudoers/parse_ldif.c +++ b/plugins/sudoers/parse_ldif.c @@ -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; -- 2.50.1