fiasco: after fiasco_unpack return back to origin directory

This commit is contained in:
Pali Rohár committed 2012-08-07 21:18:17 +02:00
1 parent 3fed685e79
commit df9fae0c0e
1 file changed
+22 -1
+22 -1
View File
@@ -473,13 +473,25 @@ 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 ) {
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;
while ( image_list ) {
@@ -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;
}