diff --git a/plugins/sudoers/editor.c b/plugins/sudoers/editor.c index 7a6164f69..5ca4eb0af 100644 --- a/plugins/sudoers/editor.c +++ b/plugins/sudoers/editor.c @@ -1,7 +1,7 @@ /* * SPDX-License-Identifier: ISC * - * Copyright (c) 2010-2015 Todd C. Miller + * Copyright (c) 2010-2015, 2020-2022 Todd C. Miller * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -103,10 +103,8 @@ copy_arg(const char *src, size_t len) if ((copy = malloc(len + 1)) != NULL) { sudoers_gc_add(GC_PTR, copy); for (dst = copy; src < src_end; ) { - if (src[0] == '\\' && src[1] != '\0') { + if (src[0] == '\\' && src[1] != '\0') src++; - continue; - } *dst++ = *src++; } *dst = '\0'; diff --git a/plugins/sudoers/regress/editor/check_editor.c b/plugins/sudoers/regress/editor/check_editor.c index 084d1628a..eef9d384e 100644 --- a/plugins/sudoers/regress/editor/check_editor.c +++ b/plugins/sudoers/regress/editor/check_editor.c @@ -1,7 +1,7 @@ /* * SPDX-License-Identifier: ISC * - * Copyright (c) 2021 Todd C. Miller + * Copyright (c) 2021-2022 Todd C. Miller * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -63,6 +63,15 @@ struct test_data { 3, { "/usr/bin/vi\\", "--", "/etc/hosts", "/bogus/file", NULL } }, + { + /* GitHub issue #179 */ + "EDITOR=sed -rie s/^\\\\(foo\\\\)/waldo\\\\1/", + 1, + { "/etc/sudoers", NULL }, + "/usr/bin/sed", + 5, + { "sed", "-rie", "s/^\\(foo\\)/waldo\\1/", "--", "/etc/sudoers", NULL } + }, { NULL } };