aboutsummaryrefslogtreecommitdiffstats
path: root/src/configuration.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/configuration.c')
-rw-r--r--src/configuration.c22
1 files changed, 5 insertions, 17 deletions
diff --git a/src/configuration.c b/src/configuration.c
index 5978e0f..2875ca3 100644
--- a/src/configuration.c
+++ b/src/configuration.c
@@ -102,8 +102,8 @@ slapt_config_t *slapt_config_t_read(const char *file_name)
/* WORKING DIR */
if (strlen(token_ptr) > strlen(SLAPT_WORKINGDIR_TOKEN)) {
- strncpy(global_config->working_dir, token_ptr + strlen(SLAPT_WORKINGDIR_TOKEN), (strlen(token_ptr) - strlen(SLAPT_WORKINGDIR_TOKEN)));
- global_config->working_dir[(strlen(token_ptr) - strlen(SLAPT_WORKINGDIR_TOKEN))] = '\0';
+ size_t working_dir_len = (strlen(token_ptr) - strlen(SLAPT_WORKINGDIR_TOKEN)) + 1;
+ slapt_strlcpy(global_config->working_dir, token_ptr + strlen(SLAPT_WORKINGDIR_TOKEN), working_dir_len);
}
} else if ((token_ptr = strstr(getline_buffer, SLAPT_EXCLUDE_TOKEN)) != NULL) {
@@ -261,22 +261,10 @@ slapt_source_t *slapt_source_t_init(const char *s)
src->url = strndup(source_string, source_len);
} else {
src->url = slapt_malloc(sizeof *src->url * (source_len + 2));
- src->url[0] = '\0';
-
- src->url = strncat(src->url, source_string, source_len);
-
- if (isblank(src->url[source_len - 1]) == 0) {
- src->url = strcat(src->url, "/");
- } else {
- if (src->url[source_len - 2] == '/') {
- src->url[source_len - 2] = '/';
- src->url[source_len - 1] = '\0';
- } else {
- src->url[source_len - 1] = '/';
- }
+ if (snprintf(src->url, source_len + 2, "%s/", source_string) != (int)(source_len + 2)) {
+ fprintf(stderr, "slapt_source_t_init error for %s\n", s);
+ exit(EXIT_FAILURE);
}
-
- src->url[source_len + 1] = '\0';
}
free(source_string);