From 7a4a988dcbc39c89b5cdfaacc514cfb1c4748197 Mon Sep 17 00:00:00 2001 From: David Grant Date: Tue, 13 Aug 2019 13:44:26 -0500 Subject: [PATCH] FS-11993 [mod_http_cache][mod_smpp] fix gcc errors when building on rpi4 buster (strncpy to snprintf) FS-11993 [mod_http_cache][mod_smpp] fix gcc errors when building on rpi4 buster (strncpy to snprintf) --- src/mod/applications/mod_http_cache/mod_http_cache.c | 4 ++-- src/mod/event_handlers/mod_smpp/mod_smpp_gateway.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/mod/applications/mod_http_cache/mod_http_cache.c b/src/mod/applications/mod_http_cache/mod_http_cache.c index e3f8d06493..7144e54da7 100644 --- a/src/mod/applications/mod_http_cache/mod_http_cache.c +++ b/src/mod/applications/mod_http_cache/mod_http_cache.c @@ -273,7 +273,7 @@ static void parse_domain(const char *url, char *domain_buf, int domain_buf_len) if (!*start) { return; } - strncpy(domain_buf, start, domain_buf_len); + snprintf(domain_buf, domain_buf_len, "%s", start); end = strchr(domain_buf, '/'); if (end) { *end = '\0'; @@ -985,7 +985,7 @@ static char *cached_url_filename_create(url_cache_t *cache, const char *url, cha /* filename is constructed from UUID and is stored in cache dir (first 2 characters of UUID) */ switch_uuid_get(&uuid); switch_uuid_format(uuid_str, &uuid); - strncpy(uuid_dir, uuid_str, 2); + snprintf(uuid_dir, sizeof(uuid_dir), "%.2s", uuid_str); dirname = switch_mprintf("%s%s%s", cache->location, SWITCH_PATH_SEPARATOR, uuid_dir); /* create sub-directory if it doesn't exist */ diff --git a/src/mod/event_handlers/mod_smpp/mod_smpp_gateway.c b/src/mod/event_handlers/mod_smpp/mod_smpp_gateway.c index ed96586039..4be9790083 100644 --- a/src/mod/event_handlers/mod_smpp/mod_smpp_gateway.c +++ b/src/mod/event_handlers/mod_smpp/mod_smpp_gateway.c @@ -112,15 +112,15 @@ switch_status_t mod_smpp_gateway_authenticate(mod_smpp_gateway_t *gateway) { strncpy( (char *)req_b->address_range, gateway->host, sizeof(req_b->address_range)); if ( gateway->system_id ) { - strncpy((char *)req_b->system_id, gateway->system_id, sizeof(req_b->system_id)); + snprintf((char *)req_b->system_id, sizeof(req_b->system_id), "%s", gateway->system_id); } if ( gateway->password ) { - strncpy((char *)req_b->password, gateway->password, sizeof(req_b->password)); + snprintf((char *)req_b->password, sizeof(req_b->password), "%s", gateway->password); } if ( gateway->system_type ) { - strncpy((char *)req_b->system_type, gateway->system_type, sizeof(req_b->system_type)); + snprintf((char *)req_b->system_type, sizeof(req_b->system_type), "%s", gateway->system_type); } req_b->interface_version = SMPP_VERSION;