diff options
author | Jose Bollo <jose.bollo@iot.bzh> | 2019-02-06 15:07:56 +0100 |
---|---|---|
committer | Jose Bollo <jose.bollo@iot.bzh> | 2019-02-06 15:07:56 +0100 |
commit | d0cb2a7a1e068a38b4a0c3216ccdbce0e33ecffb (patch) | |
tree | ecde0204132a9423ed47096cb292e9661ee30acf /src/wgtpkg-workdir.c | |
parent | 48e894bee732315d89eb5b46d2432ed45fc81a43 (diff) |
wgtpkg-pack: Ensure packing relative files
When running external ZIP program, ensures that
the files are stored with a path relative to the
root directory by changing the directory first.
Also, tiny improvement in working directory handling.
Change-Id: I3470c6c933aea9cd93dac197ff7f5e8a0ed86b23
Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
Diffstat (limited to 'src/wgtpkg-workdir.c')
-rw-r--r-- | src/wgtpkg-workdir.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/wgtpkg-workdir.c b/src/wgtpkg-workdir.c index c0fb6aa..ea37666 100644 --- a/src/wgtpkg-workdir.c +++ b/src/wgtpkg-workdir.c @@ -61,7 +61,7 @@ static void put_workdir(int fd, const char *name, size_t length) workdir[1] = 0; workdirfd = AT_FDCWD; } else { - + assert(length < sizeof workdir); memcpy(workdir, name, 1 + length); workdirfd = fd; @@ -81,6 +81,12 @@ int set_workdir(const char *name, int create) return -1; } + /* check if . */ + if (length == 1 && name[0] == '.') { + put_workdir(AT_FDCWD, name, length); + return 0; + } + /* opens the directory */ dirfd = openat(AT_FDCWD, name, O_PATH|O_DIRECTORY|O_RDONLY); if (dirfd < 0) { |