aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2026-04-16 11:52:11 -0400
committerJoseph Hunkeler <jhunkeler@gmail.com>2026-04-16 11:52:11 -0400
commitdc6b871b419159097c272fe21cdef6acece40a99 (patch)
tree1d2e4ef745106cb4a7a804698b45739a163cbe38 /src
parentf40adf8259a9f034b6fff7abff047e9a746f7ec1 (diff)
downloadstasis-dc6b871b419159097c272fe21cdef6acece40a99.tar.gz
Convert more strcat and strcpy to strn variants
Diffstat (limited to 'src')
-rw-r--r--src/cli/stasis/args.c12
-rw-r--r--src/cli/stasis/stasis_main.c8
-rw-r--r--src/cli/stasis_indexer/helpers.c38
-rw-r--r--src/cli/stasis_indexer/stasis_indexer_main.c18
-rw-r--r--src/cli/stasis_indexer/website.c2
-rw-r--r--src/lib/core/artifactory.c2
-rw-r--r--src/lib/core/conda.c12
-rw-r--r--src/lib/core/ini.c8
-rw-r--r--src/lib/core/multiprocessing.c10
-rw-r--r--src/lib/core/relocation.c8
-rw-r--r--src/lib/core/str.c8
-rw-r--r--src/lib/core/system.c2
-rw-r--r--src/lib/core/template.c2
-rw-r--r--src/lib/core/utils.c26
-rw-r--r--src/lib/delivery/delivery_install.c6
15 files changed, 81 insertions, 81 deletions
diff --git a/src/cli/stasis/args.c b/src/cli/stasis/args.c
index 696f3a6..98b4479 100644
--- a/src/cli/stasis/args.c
+++ b/src/cli/stasis/args.c
@@ -89,20 +89,20 @@ void usage(char *progname) {
char opt_long[50] = {0}; // --? [ARG]?
char opt_short[50] = {0}; // -? [ARG]?
- strcat(opt_long, "--");
- strcat(opt_long, long_options[x].name);
+ strncat(opt_long, "--", sizeof(opt_long) - strlen(opt_long) - 1);
+ strncat(opt_long, long_options[x].name, sizeof(opt_long) - strlen(opt_long) - 1);
if (long_options[x].has_arg) {
- strcat(opt_long, " ARG");
+ strncat(opt_long, " ARG", sizeof(opt_long) - strlen(opt_long) - 1);
}
if (long_options[x].val <= 'z') {
- strcat(opt_short, "-");
+ strncat(opt_short, "-", sizeof(opt_short) - strlen(opt_short) - 1);
opt_short[1] = (char) long_options[x].val;
if (long_options[x].has_arg) {
- strcat(opt_short, " ARG");
+ strncat(opt_short, " ARG", sizeof(opt_short) - strlen(opt_short) - 1);
}
} else {
- strcat(opt_short, " ");
+ strncat(opt_short, " ", sizeof(opt_short) - strlen(opt_short) - 1);
}
const char *opt_fmt = " %%-%ds\t%%s\t\t%%s";
diff --git a/src/cli/stasis/stasis_main.c b/src/cli/stasis/stasis_main.c
index 9b3c6ba..328d825 100644
--- a/src/cli/stasis/stasis_main.c
+++ b/src/cli/stasis/stasis_main.c
@@ -532,7 +532,7 @@ int main(int argc, char *argv[]) {
globals.continue_on_error = true;
break;
case 'p':
- strcpy(python_override_version, optarg);
+ strncpy(python_override_version, optarg, sizeof(python_override_version) - 1);
break;
case 'l':
globals.cpu_limit = strtol(optarg, NULL, 10);
@@ -652,9 +652,9 @@ int main(int argc, char *argv[]) {
configure_jfrog_cli(&ctx);
runtime_apply(ctx.runtime.environ);
- strcpy(env_name, ctx.info.release_name);
- strcpy(env_name_testing, env_name);
- strcat(env_name_testing, "-test");
+ strncpy(env_name, ctx.info.release_name, sizeof(env_name) - 1);
+ strncpy(env_name_testing, env_name, sizeof(env_name_testing) - 1);
+ strncat(env_name_testing, "-test", sizeof(env_name_testing) - strlen(env_name_testing) - 1);
char *envs[] = {
"release", env_name,
"testing", env_name_testing,
diff --git a/src/cli/stasis_indexer/helpers.c b/src/cli/stasis_indexer/helpers.c
index 6dc653d..27608d3 100644
--- a/src/cli/stasis_indexer/helpers.c
+++ b/src/cli/stasis_indexer/helpers.c
@@ -96,44 +96,44 @@ int pandoc_exec(const char *in_file, const char *out_file, const char *css_file,
if (!get_pandoc_version(&pandoc_version)) {
// < 2.19
if (pandoc_version < 0x02130000) {
- strcat(pandoc_versioned_args, "--self-contained ");
+ strncat(pandoc_versioned_args, "--self-contained ", sizeof(pandoc_versioned_args) - strlen(pandoc_versioned_args) - 1);
} else {
// >= 2.19
- strcat(pandoc_versioned_args, "--embed-resources ");
+ strncat(pandoc_versioned_args, "--embed-resources ", sizeof(pandoc_versioned_args) - strlen(pandoc_versioned_args) - 1);
}
// >= 1.15.0.4
if (pandoc_version >= 0x010f0004) {
- strcat(pandoc_versioned_args, "--standalone ");
+ strncat(pandoc_versioned_args, "--standalone ", sizeof(pandoc_versioned_args) - strlen(pandoc_versioned_args) - 1);
}
// >= 1.10.0.1
if (pandoc_version >= 0x010a0001) {
- strcat(pandoc_versioned_args, "-f gfm+autolink_bare_uris ");
+ strncat(pandoc_versioned_args, "-f gfm+autolink_bare_uris ", sizeof(pandoc_versioned_args) - strlen(pandoc_versioned_args) - 1);
}
// > 3.1.9
if (pandoc_version > 0x03010900) {
- strcat(pandoc_versioned_args, "-f gfm+alerts ");
+ strncat(pandoc_versioned_args, "-f gfm+alerts ", sizeof(pandoc_versioned_args) - strlen(pandoc_versioned_args) - 1);
}
}
// Converts a markdown file to html
char cmd[STASIS_BUFSIZ] = {0};
- strcpy(cmd, "pandoc ");
- strcat(cmd, pandoc_versioned_args);
+ strncpy(cmd, "pandoc ", sizeof(cmd));
+ strncat(cmd, pandoc_versioned_args, sizeof(cmd) - strlen(cmd) - 1);
if (css_file && strlen(css_file)) {
- strcat(cmd, "--css ");
- strcat(cmd, css_file);
+ strncat(cmd, "--css ", sizeof(cmd) - strlen(cmd) - 1);
+ strncat(cmd, css_file, sizeof(cmd) - strlen(cmd) - 1);
}
- strcat(cmd, " ");
- strcat(cmd, "--metadata title=\"");
- strcat(cmd, title);
- strcat(cmd, "\" ");
- strcat(cmd, "-o ");
- strcat(cmd, out_file);
- strcat(cmd, " ");
- strcat(cmd, in_file);
+ strncat(cmd, " ", sizeof(cmd) - strlen(cmd) - 1);
+ strncat(cmd, "--metadata title=\"", sizeof(cmd) - strlen(cmd) - 1);
+ strncat(cmd, title, sizeof(cmd) - strlen(cmd) - 1);
+ strncat(cmd, "\" ", sizeof(cmd) - strlen(cmd) - 1);
+ strncat(cmd, "-o ", sizeof(cmd) - strlen(cmd) - 1);
+ strncat(cmd, out_file, sizeof(cmd) - strlen(cmd) - 1);
+ strncat(cmd, " ", sizeof(cmd) - strlen(cmd) - 1);
+ strncat(cmd, in_file, sizeof(cmd) - strlen(cmd) - 1);
if (globals.verbose) {
puts(cmd);
@@ -377,8 +377,8 @@ int write_manifest(const char *path, char **exclude_path, FILE *fp) {
}
char filepath[PATH_MAX] = {0};
strncpy(filepath, path, PATH_MAX - 1);
- strcat(filepath, "/");
- strcat(filepath, rec->d_name);
+ strncat(filepath, "/", sizeof(filepath) - strlen(filepath) - 1);
+ strncat(filepath, rec->d_name, sizeof(filepath) - strlen(filepath) - 1);
if (rec->d_type == DT_DIR) {
write_manifest(filepath, exclude_path, fp);
continue;
diff --git a/src/cli/stasis_indexer/stasis_indexer_main.c b/src/cli/stasis_indexer/stasis_indexer_main.c
index 5f7ded4..63fb45c 100644
--- a/src/cli/stasis_indexer/stasis_indexer_main.c
+++ b/src/cli/stasis_indexer/stasis_indexer_main.c
@@ -13,9 +13,9 @@ int indexer_combine_rootdirs(const char *dest, char **rootdirs, const size_t roo
char destdir_with_output[PATH_MAX] = {0};
char *destdir = destdir_bare;
- strcpy(destdir_bare, dest);
- strcpy(destdir_with_output, dest);
- strcat(destdir_with_output, "/output");
+ strncpy(destdir_bare, dest, sizeof(destdir_bare) - 1);
+ strncpy(destdir_with_output, dest, sizeof(destdir_with_output) - 1);
+ strncat(destdir_with_output, "/output", sizeof(destdir_with_output) - strlen(destdir_with_output) - 1);
if (!access(destdir_with_output, F_OK)) {
destdir = destdir_with_output;
@@ -26,9 +26,9 @@ int indexer_combine_rootdirs(const char *dest, char **rootdirs, const size_t roo
char srcdir_bare[PATH_MAX] = {0};
char srcdir_with_output[PATH_MAX] = {0};
char *srcdir = srcdir_bare;
- strcpy(srcdir_bare, rootdirs[i]);
- strcpy(srcdir_with_output, rootdirs[i]);
- strcat(srcdir_with_output, "/output");
+ strncpy(srcdir_bare, rootdirs[i], sizeof(srcdir_bare) - 1);
+ strncpy(srcdir_with_output, rootdirs[i], sizeof(srcdir_with_output) - 1);
+ strncat(srcdir_with_output, "/output", sizeof(srcdir_with_output) - strlen(srcdir_with_output) - 1);
if (access(srcdir_bare, F_OK)) {
fprintf(stderr, "%s does not exist\n", srcdir_bare);
@@ -261,11 +261,11 @@ int main(const int argc, char *argv[]) {
char workdir_template[PATH_MAX] = {0};
const char *system_tmp = getenv("TMPDIR");
if (system_tmp) {
- strcat(workdir_template, system_tmp);
+ strncat(workdir_template, system_tmp, sizeof(workdir_template) - strlen(workdir_template) - 1);
} else {
- strcat(workdir_template, "/tmp");
+ strncat(workdir_template, "/tmp", sizeof(workdir_template) - strlen(workdir_template) - 1);
}
- strcat(workdir_template, "/stasis-combine.XXXXXX");
+ strncat(workdir_template, "/stasis-combine.XXXXXX", sizeof(workdir_template) - strlen(workdir_template) - 1);
char *workdir = mkdtemp(workdir_template);
if (!workdir) {
SYSERROR("Unable to create temporary directory: %s", workdir_template);
diff --git a/src/cli/stasis_indexer/website.c b/src/cli/stasis_indexer/website.c
index e758d47..8a5126d 100644
--- a/src/cli/stasis_indexer/website.c
+++ b/src/cli/stasis_indexer/website.c
@@ -36,7 +36,7 @@ int indexer_make_website(struct Delivery **ctx) {
// Replace *.md extension with *.html.
strncpy(fullpath_dest, fullpath_src, sizeof(fullpath_dest) - 1);
- gen_file_extension_str(fullpath_dest, ".html");
+ gen_file_extension_str(fullpath_dest, sizeof(fullpath_dest), ".html");
// Convert markdown to html
if (pandoc_exec(fullpath_src, fullpath_dest, have_css ? css_filename : NULL, "STASIS")) {
diff --git a/src/lib/core/artifactory.c b/src/lib/core/artifactory.c
index 6a01620..415986e 100644
--- a/src/lib/core/artifactory.c
+++ b/src/lib/core/artifactory.c
@@ -413,7 +413,7 @@ int jfrog_cli_rt_upload(struct JFRT_Auth *auth, struct JFRT_Upload *ctx, char *s
if (base) {
src = base;
} else {
- strcat(src, "/");
+ strncat(src, "/", sizeof(src) - strlen(src) - 1);
}
pushd(new_src);
}
diff --git a/src/lib/core/conda.c b/src/lib/core/conda.c
index dd336bc..491eae3 100644
--- a/src/lib/core/conda.c
+++ b/src/lib/core/conda.c
@@ -419,15 +419,15 @@ int conda_check_required() {
// Construct a "conda list" command that searches for all required packages
// using conda's (python's) regex matching
- strcat(cmd, "conda list '");
+ strncat(cmd, "conda list '", sizeof(cmd) - strlen(cmd) - 1);
for (size_t i = 0; conda_minimum_viable_tools[i] != NULL; i++) {
- strcat(cmd, "^");
- strcat(cmd, conda_minimum_viable_tools[i]);
+ strncat(cmd, "^", sizeof(cmd) - strlen(cmd) - 1);
+ strncat(cmd, conda_minimum_viable_tools[i], sizeof(cmd) - strlen(cmd) - 1);
if (conda_minimum_viable_tools[i + 1] != NULL) {
- strcat(cmd, "|");
+ strncat(cmd, "|", sizeof(cmd) - strlen(cmd) - 1);
}
}
- strcat(cmd, "' | cut -d ' ' -f 1");
+ strncat(cmd, "' | cut -d ' ' -f 1", sizeof(cmd) - strlen(cmd) - 1);
// Verify all required packages are installed
char *cmd_out = shell_output(cmd, &status);
@@ -565,7 +565,7 @@ int conda_env_create_from_uri(char *name, char *uri, char *python_version) {
unlink(tempfile);
// We'll create a new file with the same random bits, ending with .yml
- strcat(tempfile, ".yml");
+ strncat(tempfile, ".yml", sizeof(tempfile) - strlen(tempfile) - 1);
char *errmsg = NULL;
const long http_code = download(uri_fs ? uri_fs : uri, tempfile, &errmsg);
if (HTTP_ERROR(http_code)) {
diff --git a/src/lib/core/ini.c b/src/lib/core/ini.c
index cf6f670..6081678 100644
--- a/src/lib/core/ini.c
+++ b/src/lib/core/ini.c
@@ -186,8 +186,8 @@ int ini_getval(struct INIFILE *ini, char *section_name, char *key, int type, int
while ((token = strsep(&tbufp, "\n")) != NULL) {
//lstrip(token);
if (!isempty(token)) {
- strcat(data_copy, token);
- strcat(data_copy, "\n");
+ strncat(data_copy, token, BUFSIZ - strlen(data_copy) - 1);
+ strncat(data_copy, "\n", BUFSIZ - strlen(data_copy) - 1);
}
}
strip(data_copy);
@@ -353,7 +353,7 @@ int ini_data_append(struct INIFILE **ini, char *section_name, char *key, char *v
} else {
data->value = value_tmp;
}
- strcat(data->value, value);
+ strncat(data->value, value, value_len_new - strlen(data->value));
}
return 0;
}
@@ -467,7 +467,7 @@ int ini_write(struct INIFILE *ini, FILE **stream, unsigned mode) {
}
guard_array_free(parts);
strip(outvalue);
- strcat(outvalue, LINE_SEP);
+ strncat(outvalue, LINE_SEP, sizeof(outvalue) - strlen(outvalue) - 1);
fprintf(*stream, "%s = %s%s", ini->section[x]->data[y]->key, *hint == INIVAL_TYPE_STR_ARRAY ? LINE_SEP : "", outvalue);
guard_free(value);
} else {
diff --git a/src/lib/core/multiprocessing.c b/src/lib/core/multiprocessing.c
index f694ad6..09f81de 100644
--- a/src/lib/core/multiprocessing.c
+++ b/src/lib/core/multiprocessing.c
@@ -173,17 +173,17 @@ struct MultiProcessingTask *mp_pool_task(struct MultiProcessingPool *pool, const
// Set log file path
memset(slot->log_file, 0, sizeof(*slot->log_file));
if (globals.enable_task_logging) {
- strcat(slot->log_file, pool->log_root);
- strcat(slot->log_file, "/");
+ strncat(slot->log_file, pool->log_root, sizeof(slot->log_file) - strlen(slot->log_file) - 1);
+ strncat(slot->log_file, "/", sizeof(slot->log_file) - strlen(slot->log_file) - 1);
} else {
- strcpy(slot->log_file, "/dev/stdout");
+ strncpy(slot->log_file, "/dev/stdout", sizeof(slot->log_file) - 1);
}
// Set working directory
if (isempty(working_dir)) {
- strcpy(slot->working_dir, ".");
+ strncpy(slot->working_dir, ".", sizeof(slot->working_dir) - 1);
} else {
- strncpy(slot->working_dir, working_dir, PATH_MAX - 1);
+ strncpy(slot->working_dir, working_dir, sizeof(slot->working_dir) - 1);
}
// Create a temporary file to act as our intermediate command script
diff --git a/src/lib/core/relocation.c b/src/lib/core/relocation.c
index 58b829d..fce74b6 100644
--- a/src/lib/core/relocation.c
+++ b/src/lib/core/relocation.c
@@ -50,18 +50,18 @@ int replace_text(char *original, const char *target, const char *replacement, un
// replacement is shorter than the target
if (rep_len < target_len) {
// shrink the string
- strcat(buffer, replacement);
+ strncat(buffer, replacement, sizeof(buffer) - strlen(buffer) - 1);
memmove(pos, pos + target_len, strlen(pos) - target_len);
memset(pos + (strlen(pos) - target_len), 0, target_len);
} else { // replacement is longer than the target
// write the replacement value to the buffer
- strcat(buffer, replacement);
+ strncat(buffer, replacement, sizeof(buffer) - strlen(buffer) - 1);
// target consumed. jump to the end of the substring.
pos += target_len;
}
if (flags & REPLACE_TRUNCATE_AFTER_MATCH) {
if (strstr(pos, LINE_SEP)) {
- strcat(buffer, LINE_SEP);
+ strncat(buffer, LINE_SEP, sizeof(buffer) - strlen(buffer) - 1);
}
break;
}
@@ -69,7 +69,7 @@ int replace_text(char *original, const char *target, const char *replacement, un
if (!((match = strstr(pos, target)))) {
// no more matches
// append whatever remains to the buffer
- strcat(buffer, pos);
+ strncat(buffer, pos, sizeof(buffer) - strlen(buffer) - 1);
// stop
break;
}
diff --git a/src/lib/core/str.c b/src/lib/core/str.c
index 9524886..c8f9c7e 100644
--- a/src/lib/core/str.c
+++ b/src/lib/core/str.c
@@ -153,9 +153,9 @@ char *join(char **arr, const char *separator) {
result = (char *)calloc(total_bytes, sizeof(char));
for (int i = 0; i < records; i++) {
- strcat(result, arr[i]);
+ strncat(result, arr[i], total_bytes - strlen(result) - 1);
if (i < (records - 1)) {
- strcat(result, separator);
+ strncat(result, separator, total_bytes - strlen(result) - 1);
}
}
return result;
@@ -207,11 +207,11 @@ char *join_ex(char *separator, ...) {
result = calloc(size + 1, sizeof(char));
for (size_t i = 0; i < argc; i++) {
// Append argument to string
- strcat(result, argv[i]);
+ strncat(result, argv[i], size - strlen(result)); // no -1 because +1 above
// Do not append a trailing separator when we reach the last argument
if (i < (argc - 1)) {
- strcat(result, separator);
+ strncat(result, separator, size - strlen(result)); // no -1 because +1 above
}
guard_free(argv[i]);
}
diff --git a/src/lib/core/system.c b/src/lib/core/system.c
index 9eff64a..6c18cc2 100644
--- a/src/lib/core/system.c
+++ b/src/lib/core/system.c
@@ -161,7 +161,7 @@ char *shell_output(const char *command, int *status) {
result = tmp;
}
}
- strcat(result, line);
+ strncat(result, line, current_size - strlen(result) - 1);
memset(line, 0, sizeof(line));
}
*status = pclose(pp);
diff --git a/src/lib/core/template.c b/src/lib/core/template.c
index dd3c7a2..67e2e03 100644
--- a/src/lib/core/template.c
+++ b/src/lib/core/template.c
@@ -272,7 +272,7 @@ char *tpl_render(char *str) {
// Append replacement value
grow(z, &output_bytes, &output);
- strcat(output, value);
+ strncat(output, value, output_bytes - strlen(output) - 1);
guard_free(value);
output[z] = 0;
}
diff --git a/src/lib/core/utils.c b/src/lib/core/utils.c
index 76b314e..f478205 100644
--- a/src/lib/core/utils.c
+++ b/src/lib/core/utils.c
@@ -45,9 +45,9 @@ int rmtree(char *_path) {
while ((d_entity = readdir(dir)) != NULL) {
char abspath[PATH_MAX] = {0};
- strcat(abspath, path);
- strcat(abspath, DIR_SEP);
- strcat(abspath, d_entity->d_name);
+ strncat(abspath, path, sizeof(abspath) - strlen(abspath) - 1);
+ strncat(abspath, DIR_SEP, sizeof(abspath) - strlen(abspath) - 1);
+ strncat(abspath, d_entity->d_name, sizeof(abspath) - strlen(abspath) - 1);
if (!strcmp(d_entity->d_name, ".") || !strcmp(d_entity->d_name, "..") || !strcmp(abspath, path)) {
continue;
@@ -278,13 +278,13 @@ char *find_program(const char *name) {
result[0] = '\0';
while ((path_elem = strsep(&path, PATH_SEP))) {
char abspath[PATH_MAX] = {0};
- strcat(abspath, path_elem);
- strcat(abspath, DIR_SEP);
- strcat(abspath, name);
+ strncat(abspath, path_elem, sizeof(abspath) - strlen(abspath) - 1);
+ strncat(abspath, DIR_SEP, sizeof(abspath) - strlen(abspath) - 1);
+ strncat(abspath, name, sizeof(abspath) - strlen(abspath) - 1);
if (access(abspath, F_OK) < 0) {
continue;
}
- strncpy(result, abspath, sizeof(result));
+ strncpy(result, abspath, sizeof(result) - 1);
break;
}
path = path_orig;
@@ -694,7 +694,7 @@ int fix_tox_conf(const char *filename, char **result) {
return -1;
}
value = tmp;
- strcat(value, with_posargs);
+ strncat(value, with_posargs, (strlen(value) + strlen(with_posargs)) - strlen(value) - 1);
ini_setval(&toxini, INI_SETVAL_REPLACE, section_name, key, value);
}
}
@@ -829,8 +829,8 @@ int mkdirs(const char *_path, mode_t mode) {
char result[PATH_MAX] = {0};
int status = 0;
while ((token = strsep(&path, "/")) != NULL && !status) {
- strcat(result, token);
- strcat(result, "/");
+ strncat(result, token, sizeof result - strlen(result) - 1);
+ strncat(result, "/", sizeof result - strlen(result) - 1);
status = mkdir(result, mode);
if (status && errno == EEXIST) {
status = 0;
@@ -919,7 +919,7 @@ void debug_hexdump(char *data, int len) {
snprintf(addr + strlen(addr), sizeof(addr) - pos_fmt_len, pos_fmt, pos);
}
if (count == 8) {
- strcat(bytes, " ");
+ strncat(bytes, " ", sizeof(bytes) - strlen(bytes) - 1);
}
if (count > 15) {
snprintf(output, sizeof(output), "%s | %s | %s", addr, bytes, ascii);
@@ -946,11 +946,11 @@ void debug_hexdump(char *data, int len) {
if (count <= 8) {
// Add group padding
- strcat(bytes, " ");
+ strncat(bytes, " ", sizeof(bytes) - strlen(bytes) - 1);
}
const int padding = 16 - count;
for (int i = 0; i < padding; i++) {
- strcat(bytes, " ");
+ strncat(bytes, " ", sizeof(bytes) - strlen(bytes) - 1);
}
snprintf(output, DEBUG_HEXDUMP_FMT_BYTES + sizeof(addr) + sizeof(bytes) + sizeof(ascii), "%s | %s | %s", addr, bytes, ascii);
puts(output);
diff --git a/src/lib/delivery/delivery_install.c b/src/lib/delivery/delivery_install.c
index fe3bc66..4970749 100644
--- a/src/lib/delivery/delivery_install.c
+++ b/src/lib/delivery/delivery_install.c
@@ -203,7 +203,7 @@ int delivery_install_packages(struct Delivery *ctx, char *conda_install_dir, cha
}
memset(command_base, 0, sizeof(command_base));
- strcat(command_base, "install");
+ strncat(command_base, "install", sizeof(command_base) - strlen(command_base) - 1);
typedef int (*Runner)(const char *);
Runner runner = NULL;
@@ -214,13 +214,13 @@ int delivery_install_packages(struct Delivery *ctx, char *conda_install_dir, cha
}
if (INSTALL_PKG_CONDA_DEFERRED & type) {
- strcat(command_base, " --use-local");
+ strncat(command_base, " --use-local", sizeof(command_base) - strlen(command_base) - 1);
} else if (INSTALL_PKG_PIP_DEFERRED & type) {
// Don't change the baseline package set unless we're working with a
// new build. Release candidates will need to keep packages as stable
// as possible between releases.
if (!ctx->meta.based_on) {
- strcat(command_base, " --upgrade");
+ strncat(command_base, " --upgrade", sizeof(command_base) - strlen(command_base) - 1);
}
const char *command_base_fmt = " --extra-index-url 'file://%s'";
const int len = snprintf(NULL, 0, command_base_fmt, ctx->storage.wheel_artifact_dir);