[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#20796: [PATCH] Keep special meaning of "-" even for "sed -i"
From: |
Stanislav Brabec |
Subject: |
bug#20796: [PATCH] Keep special meaning of "-" even for "sed -i" |
Date: |
Mon, 22 Jun 2015 16:40:31 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 |
"sed -i -" does not fail, but it also does not do what one would expect.
It attempts to access file "./-" and edit it in place.
Keep special meaning of "-" even for "sed -i". It will cause failure,
which is what most people would expect:
sed: couldn't edit /dev/stdin: is a terminal
Note that the previous behavior could have security implications:
ln -s /etc/passwd -- -
echo root | sed -i --follow-symlinks s/root/parrot/ -
Signed-off-by: Stanislav Brabec <address@hidden>
---
sed/execute.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sed/execute.c b/sed/execute.c
index bfde525..2cba844 100644
--- a/sed/execute.c
+++ b/sed/execute.c
@@ -550,7 +550,7 @@ open_next_file(const char *name, struct input *input)
buffer.length = 0;
input->in_file_name = name;
- if (name[0] == '-' && name[1] == '\0' && !in_place_extension)
+ if (name[0] == '-' && name[1] == '\0')
{
clearerr(stdin); /* clear any stale EOF indication */
#if defined WIN32 || defined _WIN32 || defined __CYGWIN__ \
--
2.4.3
--
Best Regards / S pozdravem,
Stanislav Brabec
software developer
---------------------------------------------------------------------
SUSE LINUX, s. r. o. e-mail: address@hidden
Lihovarská 1060/12 tel: +49 911 7405384547
190 00 Praha 9 fax: +420 284 084 001
Czech Republic http://www.suse.cz/
PGP: 830B 40D5 9E05 35D8 5E27 6FA3 717C 209F A04F CD76