aboutsummaryrefslogtreecommitdiff
path: root/src/cli
diff options
context:
space:
mode:
Diffstat (limited to 'src/cli')
-rw-r--r--src/cli/stasis_indexer/helpers.c43
1 files changed, 20 insertions, 23 deletions
diff --git a/src/cli/stasis_indexer/helpers.c b/src/cli/stasis_indexer/helpers.c
index 92e2dd4..3ef96e4 100644
--- a/src/cli/stasis_indexer/helpers.c
+++ b/src/cli/stasis_indexer/helpers.c
@@ -98,48 +98,46 @@ 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) {
- strncat(pandoc_versioned_args, "--self-contained ", sizeof(pandoc_versioned_args) - strlen(pandoc_versioned_args) - 1);
+ safe_strncat(pandoc_versioned_args, "--self-contained ", sizeof(pandoc_versioned_args));
} else {
// >= 2.19
- strncat(pandoc_versioned_args, "--embed-resources ", sizeof(pandoc_versioned_args) - strlen(pandoc_versioned_args) - 1);
+ safe_strncat(pandoc_versioned_args, "--embed-resources ", sizeof(pandoc_versioned_args));
}
// >= 1.15.0.4
if (pandoc_version >= 0x010f0004) {
- strncat(pandoc_versioned_args, "--standalone ", sizeof(pandoc_versioned_args) - strlen(pandoc_versioned_args) - 1);
+ safe_strncat(pandoc_versioned_args, "--standalone ", sizeof(pandoc_versioned_args));
}
// >= 1.10.0.1
if (pandoc_version >= 0x010a0001) {
- strncat(pandoc_versioned_args, "-f gfm+autolink_bare_uris ", sizeof(pandoc_versioned_args) - strlen(pandoc_versioned_args) - 1);
+ safe_strncat(pandoc_versioned_args, "-f gfm+autolink_bare_uris ", sizeof(pandoc_versioned_args));
}
// > 3.1.9
if (pandoc_version > 0x03010900) {
- strncat(pandoc_versioned_args, "-f gfm+alerts ", sizeof(pandoc_versioned_args) - strlen(pandoc_versioned_args) - 1);
+ safe_strncat(pandoc_versioned_args, "-f gfm+alerts ", sizeof(pandoc_versioned_args));
}
}
// Converts a markdown file to html
char cmd[STASIS_BUFSIZ] = {0};
- strncpy(cmd, "pandoc ", sizeof(cmd) - 1);
- cmd[sizeof(cmd) - 1] = '\0';
+ safe_strncpy(cmd, "pandoc ", sizeof(cmd));
- strncat(cmd, pandoc_versioned_args, sizeof(cmd) - strlen(cmd) - 1);
- cmd[sizeof(cmd) - 1] = '\0';
+ safe_strncat(cmd, pandoc_versioned_args, sizeof(cmd));
if (css_file && strlen(css_file)) {
- strncat(cmd, "--css ", sizeof(cmd) - strlen(cmd) - 1);
- strncat(cmd, css_file, sizeof(cmd) - strlen(cmd) - 1);
+ safe_strncat(cmd, "--css ", sizeof(cmd));
+ safe_strncat(cmd, css_file, sizeof(cmd));
}
- 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);
+ safe_strncat(cmd, " ", sizeof(cmd));
+ safe_strncat(cmd, "--metadata title=\"", sizeof(cmd));
+ safe_strncat(cmd, title, sizeof(cmd));
+ safe_strncat(cmd, "\" ", sizeof(cmd));
+ safe_strncat(cmd, "-o ", sizeof(cmd));
+ safe_strncat(cmd, out_file, sizeof(cmd));
+ safe_strncat(cmd, " ", sizeof(cmd));
+ safe_strncat(cmd, in_file, sizeof(cmd));
if (globals.verbose) {
puts(cmd);
@@ -406,11 +404,10 @@ int write_manifest(const char *path, char **exclude_path, FILE *fp) {
continue;
}
char filepath[PATH_MAX] = {0};
- strncpy(filepath, path, PATH_MAX - 1);
- filepath[PATH_MAX - 1] = '\0';
+ safe_strncpy(filepath, path, PATH_MAX);
- strncat(filepath, "/", sizeof(filepath) - strlen(filepath) - 1);
- strncat(filepath, rec->d_name, sizeof(filepath) - strlen(filepath) - 1);
+ safe_strncat(filepath, "/", sizeof(filepath));
+ safe_strncat(filepath, rec->d_name, sizeof(filepath));
if (rec->d_type == DT_DIR) {
write_manifest(filepath, exclude_path, fp);