diff options
author | Christian Neukirchen <chneukirchen@gmail.com> | 2016-07-20 23:10:35 +0200 |
---|---|---|
committer | Christian Neukirchen <chneukirchen@gmail.com> | 2016-07-20 23:10:35 +0200 |
commit | d52fa6bf4da9cb9b2039750adca97f91ec503cab (patch) | |
tree | 77101e50fa1aab90472e4f58582b69603437d7ad | |
parent | 9545981777e56a1f52a3070f318dc31d15d31d14 (diff) | |
download | mblaze-d52fa6bf4da9cb9b2039750adca97f91ec503cab.tar.gz mblaze-d52fa6bf4da9cb9b2039750adca97f91ec503cab.tar.xz mblaze-d52fa6bf4da9cb9b2039750adca97f91ec503cab.zip |
mshow: don't extract to absolute paths
duh.
-rw-r--r-- | mshow.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/mshow.c b/mshow.c index cd8bbef..7dc6174 100644 --- a/mshow.c +++ b/mshow.c @@ -308,10 +308,18 @@ static int extract_argc; static char **extract_argv; static int extract_stdout; + +static const char * +basenam(const char *s) +{ + char *r = strrchr(s, '/'); + return r ? r + 1 : s; +} + static int writefile(char *name, char *buf, ssize_t len) { - int fd = open(name, O_CREAT | O_EXCL | O_WRONLY, 0666); + int fd = open(basenam(name), O_CREAT | O_EXCL | O_WRONLY, 0666); if (fd == -1) { perror("open"); return -1; |