diff options
author | delphij <delphij@FreeBSD.org> | 2015-08-05 22:05:02 +0000 |
---|---|---|
committer | delphij <delphij@FreeBSD.org> | 2015-08-05 22:05:02 +0000 |
commit | b64e10546f51b85523e51e5487e5a9463394feac (patch) | |
tree | 08935a1a29c46db433354b93a3041e5b8e90ef22 /usr.bin | |
parent | c527db206bed3fb6312aeaec912eec311c9fa9f0 (diff) | |
download | FreeBSD-src-b64e10546f51b85523e51e5487e5a9463394feac.zip FreeBSD-src-b64e10546f51b85523e51e5487e5a9463394feac.tar.gz |
Fix patch(1) shell injection vulnerability via ed(1). [SA-15:18]
Fix routed remote denial of service vulnerability. [SA-15:19]
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/patch/pathnames.h | 2 | ||||
-rw-r--r-- | usr.bin/patch/pch.c | 18 |
2 files changed, 16 insertions, 4 deletions
diff --git a/usr.bin/patch/pathnames.h b/usr.bin/patch/pathnames.h index d31300e..79d8fae 100644 --- a/usr.bin/patch/pathnames.h +++ b/usr.bin/patch/pathnames.h @@ -9,4 +9,4 @@ #include <paths.h> -#define _PATH_ED "/bin/ed" +#define _PATH_RED "/bin/red" diff --git a/usr.bin/patch/pch.c b/usr.bin/patch/pch.c index aacafc8..08a7447 100644 --- a/usr.bin/patch/pch.c +++ b/usr.bin/patch/pch.c @@ -1,4 +1,3 @@ - /*- * Copyright 1986, Larry Wall * @@ -1409,13 +1408,14 @@ do_ed_script(void) char *t; off_t beginning_of_this_line; FILE *pipefp = NULL; + int continuation; if (!skip_rest_of_patch) { if (copy_file(filearg[0], TMPOUTNAME) < 0) { unlink(TMPOUTNAME); fatal("can't create temp file %s", TMPOUTNAME); } - snprintf(buf, buf_size, "%s%s%s", _PATH_ED, + snprintf(buf, buf_size, "%s%s%s", _PATH_RED, verbose ? " " : " -s ", TMPOUTNAME); pipefp = popen(buf, "w"); } @@ -1433,7 +1433,19 @@ do_ed_script(void) (*t == 'a' || *t == 'c' || *t == 'd' || *t == 'i' || *t == 's')) { if (pipefp != NULL) fputs(buf, pipefp); - if (*t != 'd') { + if (*t == 's') { + for (;;) { + continuation = 0; + t = strchr(buf, '\0') - 1; + while (--t >= buf && *t == '\\') + continuation = !continuation; + if (!continuation || + pgets(true) == 0) + break; + if (pipefp != NULL) + fputs(buf, pipefp); + } + } else if (*t != 'd') { while (pgets(true)) { p_input_line++; if (pipefp != NULL) |