Convert most strlcat() calls to use destination bound from sizeof()
This commit helps to ensure correctness of strlcat() calls in support of fixing issue #2.
This commit is contained in:
parent
b3f55bf1ab
commit
12a6e9e93a
@ -1117,10 +1117,10 @@ save_args(int argc, char **argv, const char * const args_save_file)
|
|||||||
fprintf(stderr, "argument string too long, exiting.\n");
|
fprintf(stderr, "argument string too long, exiting.\n");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
strlcat(args_str, argv[i], MAX_PATH_LEN);
|
strlcat(args_str, argv[i], sizeof(args_str));
|
||||||
strlcat(args_str, " ", MAX_PATH_LEN);
|
strlcat(args_str, " ", sizeof(args_str));
|
||||||
}
|
}
|
||||||
strlcat(args_str, "\n", MAX_PATH_LEN);
|
strlcat(args_str, "\n", sizeof(args_str));
|
||||||
if(write(args_file_fd, args_str, strlen(args_str))
|
if(write(args_file_fd, args_str, strlen(args_str))
|
||||||
!= strlen(args_str)) {
|
!= strlen(args_str)) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
|
|||||||
@ -323,9 +323,9 @@ validate_options(fko_srv_options_t *opts)
|
|||||||
strlcpy(tmp_path, opts->config[CONF_FWKNOP_RUN_DIR], sizeof(tmp_path));
|
strlcpy(tmp_path, opts->config[CONF_FWKNOP_RUN_DIR], sizeof(tmp_path));
|
||||||
|
|
||||||
if(tmp_path[strlen(tmp_path)-1] != '/')
|
if(tmp_path[strlen(tmp_path)-1] != '/')
|
||||||
strlcat(tmp_path, "/", MAX_PATH_LEN);
|
strlcat(tmp_path, "/", sizeof(tmp_path));
|
||||||
|
|
||||||
strlcat(tmp_path, DEF_PID_FILENAME, MAX_PATH_LEN);
|
strlcat(tmp_path, DEF_PID_FILENAME, sizeof(tmp_path));
|
||||||
|
|
||||||
set_config_entry(opts, CONF_FWKNOP_PID_FILE, tmp_path);
|
set_config_entry(opts, CONF_FWKNOP_PID_FILE, tmp_path);
|
||||||
}
|
}
|
||||||
@ -339,14 +339,14 @@ validate_options(fko_srv_options_t *opts)
|
|||||||
strlcpy(tmp_path, opts->config[CONF_FWKNOP_RUN_DIR], sizeof(tmp_path));
|
strlcpy(tmp_path, opts->config[CONF_FWKNOP_RUN_DIR], sizeof(tmp_path));
|
||||||
|
|
||||||
if(tmp_path[strlen(tmp_path)-1] != '/')
|
if(tmp_path[strlen(tmp_path)-1] != '/')
|
||||||
strlcat(tmp_path, "/", MAX_PATH_LEN);
|
strlcat(tmp_path, "/", sizeof(tmp_path));
|
||||||
|
|
||||||
|
|
||||||
#if USE_FILE_CACHE
|
#if USE_FILE_CACHE
|
||||||
strlcat(tmp_path, DEF_DIGEST_CACHE_FILENAME, MAX_PATH_LEN);
|
strlcat(tmp_path, DEF_DIGEST_CACHE_FILENAME, sizeof(tmp_path));
|
||||||
set_config_entry(opts, CONF_DIGEST_FILE, tmp_path);
|
set_config_entry(opts, CONF_DIGEST_FILE, tmp_path);
|
||||||
#else
|
#else
|
||||||
strlcat(tmp_path, DEF_DIGEST_CACHE_DB_FILENAME, MAX_PATH_LEN);
|
strlcat(tmp_path, DEF_DIGEST_CACHE_DB_FILENAME, sizeof(tmp_path));
|
||||||
set_config_entry(opts, CONF_DIGEST_DB_FILE, tmp_path);
|
set_config_entry(opts, CONF_DIGEST_DB_FILE, tmp_path);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user