aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lib/core/conda.c34
1 files changed, 28 insertions, 6 deletions
diff --git a/src/lib/core/conda.c b/src/lib/core/conda.c
index c81e6cc..44af34d 100644
--- a/src/lib/core/conda.c
+++ b/src/lib/core/conda.c
@@ -62,17 +62,39 @@ int micromamba(struct MicromambaInfo *info, char *command, ...) {
}
int python_exec(const char *args) {
- char command[PATH_MAX] = {0};
- snprintf(command, sizeof(command) - 1, "python %s", args);
+ int result = -1;
+ const char *command_base = "python ";
+ const size_t required_len = strlen(command_base) + strlen(args) + 1;
+
+ char *command = calloc(required_len, sizeof(*command));
+ if (!command) {
+ SYSERROR("Unable to allocate %zu bytes for command string", required_len);
+ return result;
+ }
+ snprintf(command, required_len, "%s%s", command_base, args);
msg(STASIS_MSG_L3, "Executing: %s\n", command);
- return system(command);
+
+ result = system(command);
+ guard_free(command);
+ return result;
}
int pip_exec(const char *args) {
- char command[PATH_MAX] = {0};
- snprintf(command, sizeof(command) - 1, "python -m pip %s", args);
+ int result = -1;
+ const char *command_base = "python -m pip ";
+ const size_t required_len = strlen(command_base) + strlen(args) + 1;
+
+ char *command = calloc(required_len, sizeof(*command));
+ if (!command) {
+ SYSERROR("Unable to allocate %zu bytes for command string", required_len);
+ return result;
+ }
+ snprintf(command, required_len, "%s%s", command_base, args);
msg(STASIS_MSG_L3, "Executing: %s\n", command);
- return system(command);
+
+ result = system(command);
+ guard_free(command);
+ return result;
}
static const char *PKG_ERROR_STR[] = {