fix gcc -Wstrlcpy-strlcat-size warnings
This commit is contained in:
@@ -1859,7 +1859,7 @@ set_defaults(fko_cli_options_t *options)
|
||||
void
|
||||
config_init(fko_cli_options_t *options, int argc, char **argv)
|
||||
{
|
||||
int cmd_arg, index, is_err;
|
||||
int cmd_arg, index, is_err, rlen=0;
|
||||
fko_var_bitmask_t var_bitmask;
|
||||
char rcfile[MAX_PATH_LEN] = {0};
|
||||
|
||||
@@ -2165,13 +2165,14 @@ config_init(fko_cli_options_t *options, int argc, char **argv)
|
||||
case RESOLVE_URL:
|
||||
if(options->resolve_url != NULL)
|
||||
free(options->resolve_url);
|
||||
options->resolve_url = calloc(1, strlen(optarg)+1);
|
||||
rlen = strlen(optarg) + 1;
|
||||
options->resolve_url = calloc(1, rlen);
|
||||
if(options->resolve_url == NULL)
|
||||
{
|
||||
log_msg(LOG_VERBOSITY_ERROR, "Memory allocation error for resolve URL.");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
strlcpy(options->resolve_url, optarg, strlen(optarg)+1);
|
||||
strlcpy(options->resolve_url, optarg, rlen);
|
||||
add_var_to_bitmask(FWKNOP_CLI_ARG_RESOLVE_URL, &var_bitmask);
|
||||
break;
|
||||
case SHOW_LAST_ARGS:
|
||||
|
||||
+4
-3
@@ -970,7 +970,7 @@ run_last_args(fko_cli_options_t *options, const char * const args_save_file)
|
||||
FILE *args_file_ptr = NULL;
|
||||
|
||||
int current_arg_ctr = 0;
|
||||
int argc_new = 0, args_broken = 0;
|
||||
int argc_new = 0, args_broken = 0, buf_size=0;
|
||||
int i = 0;
|
||||
|
||||
char args_str[MAX_LINE_LEN] = {0};
|
||||
@@ -1001,14 +1001,15 @@ run_last_args(fko_cli_options_t *options, const char * const args_save_file)
|
||||
else
|
||||
{
|
||||
arg_tmp[current_arg_ctr] = '\0';
|
||||
argv_new[argc_new] = calloc(1, strlen(arg_tmp)+1);
|
||||
buf_size = strlen(arg_tmp) + 1;
|
||||
argv_new[argc_new] = calloc(1, buf_size);
|
||||
if (argv_new[argc_new] == NULL)
|
||||
{
|
||||
log_msg(LOG_VERBOSITY_ERROR, "[*] calloc failure for cmd line arg.");
|
||||
fclose(args_file_ptr);
|
||||
return 0;
|
||||
}
|
||||
strlcpy(argv_new[argc_new], arg_tmp, strlen(arg_tmp)+1);
|
||||
strlcpy(argv_new[argc_new], arg_tmp, buf_size);
|
||||
current_arg_ctr = 0;
|
||||
argc_new++;
|
||||
if(argc_new >= MAX_CMDLINE_ARGS)
|
||||
|
||||
+1
-1
@@ -337,7 +337,7 @@ add_source_mask(fko_srv_options_t *opts, acc_stanza_t *acc, const char *ip)
|
||||
new_sle = NULL;
|
||||
return 0;
|
||||
}
|
||||
strlcpy(ip_str, ip, strlen(ip)+1);
|
||||
strlcpy(ip_str, ip, sizeof(ip_str));
|
||||
}
|
||||
|
||||
if(inet_aton(ip_str, &in) == 0)
|
||||
|
||||
Reference in New Issue
Block a user