aboutsummaryrefslogtreecommitdiff
path: root/src/cli
diff options
context:
space:
mode:
Diffstat (limited to 'src/cli')
-rw-r--r--src/cli/stasis/stasis_main.c10
-rw-r--r--src/cli/stasis_indexer/helpers.c7
-rw-r--r--src/cli/stasis_indexer/junitxml_report.c10
-rw-r--r--src/cli/stasis_indexer/stasis_indexer_main.c11
-rw-r--r--src/cli/stasis_indexer/website.c3
5 files changed, 38 insertions, 3 deletions
diff --git a/src/cli/stasis/stasis_main.c b/src/cli/stasis/stasis_main.c
index 01a126e..c04e88b 100644
--- a/src/cli/stasis/stasis_main.c
+++ b/src/cli/stasis/stasis_main.c
@@ -20,6 +20,7 @@ static void setup_sysconfdir() {
} else {
strncpy(stasis_sysconfdir_tmp, STASIS_SYSCONFDIR, sizeof(stasis_sysconfdir_tmp) - 1);
}
+ stasis_sysconfdir_tmp[sizeof(stasis_sysconfdir_tmp) - 1] = '\0';
globals.sysconfdir = realpath(stasis_sysconfdir_tmp, NULL);
if (!globals.sysconfdir) {
@@ -521,6 +522,8 @@ static char *center_text(const char *s, const size_t maxwidth) {
}
result[i++] = 'v';
strncpy(&result[i], s, maxwidth - middle - 1);
+ result[maxwidth - 1] = '\0';
+
return result;
}
@@ -571,6 +574,7 @@ int main(int argc, char *argv[]) {
break;
case 'p':
strncpy(python_override_version, optarg, sizeof(python_override_version) - 1);
+ python_override_version[sizeof(python_override_version) - 1] = '\0';
break;
case 'l':
globals.cpu_limit = strtol(optarg, NULL, 10);
@@ -707,8 +711,14 @@ int main(int argc, char *argv[]) {
runtime_apply(ctx.runtime.environ);
strncpy(env_name, ctx.info.release_name, sizeof(env_name) - 1);
+ env_name[sizeof(env_name) - 1] = '\0';
+
strncpy(env_name_testing, env_name, sizeof(env_name_testing) - 1);
+ env_name_testing[sizeof(env_name_testing) - 1] = '\0';
+
strncat(env_name_testing, "-test", sizeof(env_name_testing) - strlen(env_name_testing) - 1);
+ env_name_testing[sizeof(env_name_testing) - 1] = '\0';
+
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 23e4f5a..86a20e4 100644
--- a/src/cli/stasis_indexer/helpers.c
+++ b/src/cli/stasis_indexer/helpers.c
@@ -121,7 +121,11 @@ int pandoc_exec(const char *in_file, const char *out_file, const char *css_file,
// Converts a markdown file to html
char cmd[STASIS_BUFSIZ] = {0};
strncpy(cmd, "pandoc ", sizeof(cmd) - 1);
+ cmd[sizeof(cmd) - 1] = '\0';
+
strncat(cmd, pandoc_versioned_args, sizeof(cmd) - strlen(cmd) - 1);
+ cmd[sizeof(cmd) - 1] = '\0';
+
if (css_file && strlen(css_file)) {
strncat(cmd, "--css ", sizeof(cmd) - strlen(cmd) - 1);
strncat(cmd, css_file, sizeof(cmd) - strlen(cmd) - 1);
@@ -397,8 +401,11 @@ int write_manifest(const char *path, char **exclude_path, FILE *fp) {
}
char filepath[PATH_MAX] = {0};
strncpy(filepath, path, PATH_MAX - 1);
+ filepath[PATH_MAX - 1] = '\0';
+
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/junitxml_report.c b/src/cli/stasis_indexer/junitxml_report.c
index d30ee09..4eae7f7 100644
--- a/src/cli/stasis_indexer/junitxml_report.c
+++ b/src/cli/stasis_indexer/junitxml_report.c
@@ -36,10 +36,15 @@ static int write_report_output(struct Delivery *ctx, FILE *destfp, const char *x
char result_outfile[PATH_MAX] = {0};
char *short_name_pattern = NULL;
- asprintf(&short_name_pattern, "-%s", ctx->info.release_name);
+ if (asprintf(&short_name_pattern, "-%s", ctx->info.release_name) < 0 || !short_name_pattern) {
+ SYSERROR("%s", "unable to allocate bytes for short name pattern");
+ return -1;
+ }
char short_name[PATH_MAX] = {0};
strncpy(short_name, bname, sizeof(short_name) - 1);
+ short_name[sizeof(short_name) - 1] = '\0';
+
replace_text(short_name, short_name_pattern, "", 0);
replace_text(short_name, "results-", "", 0);
guard_free(short_name_pattern);
@@ -52,8 +57,7 @@ static int write_report_output(struct Delivery *ctx, FILE *destfp, const char *x
testsuite->passed, testsuite->failures,
testsuite->skipped, testsuite->errors);
- snprintf(result_outfile, sizeof(result_outfile) - strlen(bname) - 3, "%s.md",
- bname);
+ snprintf(result_outfile, sizeof(result_outfile) - strlen(bname), "%s.md", bname);
guard_free(bname);
FILE *resultfp = fopen(result_outfile, "w+");
diff --git a/src/cli/stasis_indexer/stasis_indexer_main.c b/src/cli/stasis_indexer/stasis_indexer_main.c
index d475c15..5a92014 100644
--- a/src/cli/stasis_indexer/stasis_indexer_main.c
+++ b/src/cli/stasis_indexer/stasis_indexer_main.c
@@ -14,8 +14,13 @@ int indexer_combine_rootdirs(const char *dest, char **rootdirs, const size_t roo
char *destdir = destdir_bare;
strncpy(destdir_bare, dest, sizeof(destdir_bare) - 1);
+ destdir[sizeof(destdir_bare) - 1] = '\0';
+
strncpy(destdir_with_output, dest, sizeof(destdir_with_output) - 1);
+ destdir_with_output[sizeof(destdir_with_output) - 1] = '\0';
+
strncat(destdir_with_output, "/output", sizeof(destdir_with_output) - strlen(destdir_with_output) - 1);
+ destdir_with_output[sizeof(destdir_with_output) - 1] = '\0';
if (!access(destdir_with_output, F_OK)) {
destdir = destdir_with_output;
@@ -27,8 +32,13 @@ int indexer_combine_rootdirs(const char *dest, char **rootdirs, const size_t roo
char srcdir_with_output[PATH_MAX] = {0};
char *srcdir = srcdir_bare;
strncpy(srcdir_bare, rootdirs[i], sizeof(srcdir_bare) - 1);
+ srcdir_bare[sizeof(srcdir_bare) - 1] = '\0';
+
strncpy(srcdir_with_output, rootdirs[i], sizeof(srcdir_with_output) - 1);
+ srcdir_with_output[sizeof(srcdir_with_output) - 1] = '\0';
+
strncat(srcdir_with_output, "/output", sizeof(srcdir_with_output) - strlen(srcdir_with_output) - 1);
+ srcdir_with_output[sizeof(srcdir_with_output) - 1] = '\0';
if (access(srcdir_bare, F_OK)) {
fprintf(stderr, "%s does not exist\n", srcdir_bare);
@@ -251,6 +261,7 @@ int main(const int argc, char *argv[]) {
} else {
strncpy(stasis_sysconfdir_tmp, STASIS_SYSCONFDIR, sizeof(stasis_sysconfdir_tmp) - 1);
}
+ stasis_sysconfdir_tmp[sizeof(stasis_sysconfdir_tmp) - 1] = '\0';
globals.sysconfdir = realpath(stasis_sysconfdir_tmp, NULL);
if (!globals.sysconfdir) {
diff --git a/src/cli/stasis_indexer/website.c b/src/cli/stasis_indexer/website.c
index 8a5126d..aa6e2a5 100644
--- a/src/cli/stasis_indexer/website.c
+++ b/src/cli/stasis_indexer/website.c
@@ -36,6 +36,8 @@ int indexer_make_website(struct Delivery **ctx) {
// Replace *.md extension with *.html.
strncpy(fullpath_dest, fullpath_src, sizeof(fullpath_dest) - 1);
+ fullpath_dest[sizeof(fullpath_dest) - 1] = '\0';
+
gen_file_extension_str(fullpath_dest, sizeof(fullpath_dest), ".html");
// Convert markdown to html
@@ -53,6 +55,7 @@ int indexer_make_website(struct Delivery **ctx) {
char link_from[PATH_MAX] = {0};
char link_dest[PATH_MAX] = {0};
strncpy(link_from, "README.html", sizeof(link_from) - 1);
+ link_dest[sizeof(link_dest) - 1] = '\0';
snprintf(link_dest, sizeof(link_dest), "%s/%s", root, "index.html");
if (symlink(link_from, link_dest)) {
SYSERROR("Warning: symlink(%s, %s) failed: %s", link_from, link_dest, strerror(errno));