aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2025-06-10 12:49:15 -0400
committerJoseph Hunkeler <jhunkeler@gmail.com>2025-06-10 12:50:54 -0400
commit31bea62c83a260e33a2b282d9b2da19ef264de0d (patch)
treebe94ff3ca932931c70f6bb241a4367c4aac3015a /src
parent8fe9306c1655baa6f6b57edd56c9504132cb8232 (diff)
downloadstasis-31bea62c83a260e33a2b282d9b2da19ef264de0d.tar.gz
Dynamic pip_exec()
Diffstat (limited to 'src')
-rw-r--r--src/lib/core/conda.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/lib/core/conda.c b/src/lib/core/conda.c
index 62a81ef..44af34d 100644
--- a/src/lib/core/conda.c
+++ b/src/lib/core/conda.c
@@ -80,10 +80,21 @@ int python_exec(const char *args) {
}
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[] = {