From 12a6e9e93a739494a985620619878a4a7983558c Mon Sep 17 00:00:00 2001 From: Michael Rash Date: Sat, 27 Apr 2013 20:41:12 -0400 Subject: [PATCH] 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. --- client/fwknop.c | 6 +++--- server/config_init.c | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/client/fwknop.c b/client/fwknop.c index e6912166..6763d760 100644 --- a/client/fwknop.c +++ b/client/fwknop.c @@ -1117,10 +1117,10 @@ save_args(int argc, char **argv, const char * const args_save_file) fprintf(stderr, "argument string too long, exiting.\n"); exit(EXIT_FAILURE); } - strlcat(args_str, argv[i], MAX_PATH_LEN); - strlcat(args_str, " ", MAX_PATH_LEN); + strlcat(args_str, argv[i], sizeof(args_str)); + 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)) != strlen(args_str)) { fprintf(stderr, diff --git a/server/config_init.c b/server/config_init.c index a401a99d..202df8b1 100644 --- a/server/config_init.c +++ b/server/config_init.c @@ -323,9 +323,9 @@ validate_options(fko_srv_options_t *opts) strlcpy(tmp_path, opts->config[CONF_FWKNOP_RUN_DIR], sizeof(tmp_path)); 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); } @@ -339,14 +339,14 @@ validate_options(fko_srv_options_t *opts) strlcpy(tmp_path, opts->config[CONF_FWKNOP_RUN_DIR], sizeof(tmp_path)); if(tmp_path[strlen(tmp_path)-1] != '/') - strlcat(tmp_path, "/", MAX_PATH_LEN); + strlcat(tmp_path, "/", sizeof(tmp_path)); #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); #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); #endif }