libmpm

morphux C package management library
Log | Files | Refs | Submodules | README | LICENSE | git clone https://git.ne02ptzero.me/git/libmpm

commit 17c097a671cd2dd147d12a905c9f16bce9dcc270
parent e127a347262dd8c1107b47811c5602fc2cbb4438
Author: Ne02ptzero <louis@ne02ptzero.me>
Date:   Fri, 19 May 2017 19:04:12 +0200

Fix(Compile): Checks after chdir

Diffstat:
Msrc/compile.c | 13++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/compile.c b/src/compile.c @@ -59,12 +59,15 @@ bool patch_package(compile_t *ctx) { DIR *dir = opendir(PACKER_PATCH_DIR); struct dirent *dinfo = NULL; char *cmd = NULL; + bool status = false; /* Nothing to patch, we're good */ if (dir == NULL) return true; - chdir(PACKER_SRC_DIR); + if (chdir(PACKER_SRC_DIR) == -1) + goto end; + while ((dinfo = readdir(dir))) { /* Skip .* files */ @@ -79,10 +82,14 @@ bool patch_package(compile_t *ctx) { } } - chdir(".."); + if (chdir("..") == -1) + goto end; + + status = true; +end: closedir(dir); ctx->state = INST_STATE_PATCHING; - return true; + return status; } bool configure_package(compile_t *ctx) {