2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-08-31 06:15:37 +00:00

Treat a lone backslash at the end of a string as a literal backslash.

GitHub issue #99
This commit is contained in:
Todd C. Miller
2021-04-24 14:19:46 -06:00
parent d6d2e3488b
commit 5e5131dec3
4 changed files with 179 additions and 6 deletions

View File

@@ -41,7 +41,7 @@ static const char *
wordsplit(const char *str, const char *endstr, const char **last)
{
const char *cp;
debug_decl(wordsplit, SUDO_DEBUG_UTIL);
debug_decl(wordsplit, SUDOERS_DEBUG_UTIL);
/* If no str specified, use last ptr (if any). */
if (str == NULL) {
@@ -72,7 +72,7 @@ wordsplit(const char *str, const char *endstr, const char **last)
/* Scan str until we encounter white space. */
for (cp = str; cp < endstr; cp++) {
if (*cp == '\\') {
if (cp[0] == '\\' && cp[1] != '\0') {
/* quoted char, do not interpret */
cp++;
continue;
@@ -96,7 +96,7 @@ copy_arg(const char *src, size_t len)
if ((copy = malloc(len + 1)) != NULL) {
for (dst = copy; src < src_end; ) {
if (*src == '\\') {
if (src[0] == '\\' && src[1] != '\0') {
src++;
continue;
}