From df9fae0c0ee189519545a0d01488e98c9aac8836 Mon Sep 17 00:00:00 2001 From: Pali Rohár Date: Tue, 7 Aug 2012 21:18:17 +0200 Subject: fiasco: after fiasco_unpack return back to origin directory --- src/fiasco2.c | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/fiasco2.c b/src/fiasco2.c index b155ec4..4b743dd 100644 --- a/src/fiasco2.c +++ b/src/fiasco2.c @@ -473,11 +473,23 @@ int fiasco_unpack(struct fiasco * fiasco, const char * dir) { struct image * image; struct image_list * image_list; uint32_t size; + char cwd[256]; unsigned char buf[4096]; - if ( dir && chdir(dir) < 0 ) { - perror("Cannot chdir"); - return -1; + if ( dir ) { + + memset(cwd, 0, sizeof(cwd)); + + if ( ! getcwd(cwd, sizeof(cwd)) ) { + perror("Cannot getcwd"); + return -1; + } + + if ( chdir(dir) < 0 ) { + perror("Cannot chdir"); + return -1; + } + } image_list = fiasco->first; @@ -556,6 +568,15 @@ int fiasco_unpack(struct fiasco * fiasco, const char * dir) { } + if ( dir ) { + + if ( chdir(cwd) < 0 ) { + perror("Cannot chdir"); + return -1; + } + + } + return 0; } -- cgit v1.2.3