diff options
author | Joseph Hunkeler <jhunkeler@gmail.com> | 2024-09-20 08:42:33 -0400 |
---|---|---|
committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2024-09-20 13:11:45 -0400 |
commit | d76321976cfe42bb03b5e7e48ac9f6d95d97b14a (patch) | |
tree | d4aa958e4719641a9fb8d3367a3f8b6ef327ab63 | |
parent | 8608e897410ca4a5ff94dd9868834a00214526f5 (diff) | |
download | stasis-d76321976cfe42bb03b5e7e48ac9f6d95d97b14a.tar.gz |
Die if the current working directory cannot be determined
-rw-r--r-- | src/template_func_proto.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/template_func_proto.c b/src/template_func_proto.c index ebb595e..9f1283f 100644 --- a/src/template_func_proto.c +++ b/src/template_func_proto.c @@ -74,7 +74,10 @@ int get_junitxml_file_entrypoint(void *frame, void *data_out) { const struct Delivery *ctx = (const struct Delivery *) f->data_in; char cwd[PATH_MAX] = {0}; - getcwd(cwd, PATH_MAX - 1); + if (!getcwd(cwd, PATH_MAX - 1)) { + SYSERROR("unable to determine current working directory: %s", strerror(errno)); + return -1; + } char nametmp[PATH_MAX] = {0}; strcpy(nametmp, cwd); char *name = path_basename(nametmp); @@ -96,7 +99,10 @@ int get_basetemp_dir_entrypoint(void *frame, void *data_out) { const struct Delivery *ctx = (const struct Delivery *) f->data_in; char cwd[PATH_MAX] = {0}; - getcwd(cwd, PATH_MAX - 1); + if (!getcwd(cwd, PATH_MAX - 1)) { + SYSERROR("unable to determine current working directory: %s", strerror(errno)); + return -1; + } char nametmp[PATH_MAX] = {0}; strcpy(nametmp, cwd); char *name = path_basename(nametmp); |