From 74dc62b1480fa7389d73f0a1dec4c75bbb512de6 Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Tue, 30 Apr 2019 11:11:49 -0500 Subject: [PATCH] drivers: Silence strncpy use warnings --- drivers/atmodem/call-meter.c | 3 ++- drivers/ifxmodem/gprs-context.c | 13 +++++++------ drivers/telitmodem/gprs-context-ncm.c | 11 ++++++----- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/drivers/atmodem/call-meter.c b/drivers/atmodem/call-meter.c index 3766f459..7996a9f2 100644 --- a/drivers/atmodem/call-meter.c +++ b/drivers/atmodem/call-meter.c @@ -27,6 +27,7 @@ #include #include +#include #include #include @@ -233,7 +234,7 @@ static void cpuc_query_cb(gboolean ok, if (g_at_result_iter_next_string(&iter, ¤cy) != TRUE) goto error; - strncpy(currency_buf, currency, sizeof(currency_buf)); + l_strlcpy(currency_buf, currency, sizeof(currency_buf)); if (g_at_result_iter_next_string(&iter, &ppu) != TRUE) goto error; diff --git a/drivers/ifxmodem/gprs-context.c b/drivers/ifxmodem/gprs-context.c index 19be6dfe..2de6b4f6 100644 --- a/drivers/ifxmodem/gprs-context.c +++ b/drivers/ifxmodem/gprs-context.c @@ -29,6 +29,7 @@ #include #include +#include #include #include @@ -201,8 +202,8 @@ static void dns_cb(gboolean ok, GAtResult *result, gpointer user_data) if ((unsigned int) cid == gcd->active_context) { found = TRUE; - strncpy(gcd->dns1, dns1, sizeof(gcd->dns1)); - strncpy(gcd->dns2, dns2, sizeof(gcd->dns2)); + l_strlcpy(gcd->dns1, dns1, sizeof(gcd->dns1)); + l_strlcpy(gcd->dns2, dns2, sizeof(gcd->dns2)); } } @@ -251,7 +252,7 @@ static void address_cb(gboolean ok, GAtResult *result, gpointer user_data) if (!g_at_result_iter_next_string(&iter, &address)) goto error; - strncpy(gcd->address, address, sizeof(gcd->address)); + l_strlcpy(gcd->address, address, sizeof(gcd->address)); if (g_at_chat_send(gcd->chat, "AT+XDNS?", xdns_prefix, dns_cb, gc, NULL) > 0) @@ -347,8 +348,8 @@ static void cgcontrdp_cb(gboolean ok, GAtResult *result, gpointer user_data) break; } - strncpy(gcd->dns1, dns[0], sizeof(gcd->dns1)); - strncpy(gcd->dns2, dns[1], sizeof(gcd->dns2)); + l_strlcpy(gcd->dns1, dns[0], sizeof(gcd->dns1)); + l_strlcpy(gcd->dns2, dns[1], sizeof(gcd->dns2)); dns[2] = 0; DBG("DNS: %s, %s\n", gcd->dns1, gcd->dns2); @@ -391,7 +392,7 @@ static void cgcontrdp_cb(gboolean ok, GAtResult *result, gpointer user_data) } if (gw) - strncpy(gcd->gateway, gw, sizeof(gcd->gateway)); + l_strlcpy(gcd->gateway, gw, sizeof(gcd->gateway)); gcd->state = STATE_ACTIVE; diff --git a/drivers/telitmodem/gprs-context-ncm.c b/drivers/telitmodem/gprs-context-ncm.c index 93db7233..cd6d4545 100644 --- a/drivers/telitmodem/gprs-context-ncm.c +++ b/drivers/telitmodem/gprs-context-ncm.c @@ -25,6 +25,7 @@ #include #include +#include #include #include @@ -171,13 +172,13 @@ static void contrdp_cb(gboolean ok, GAtResult *result, gpointer user_data) found = TRUE; if (strcmp(gcd->address, "") != 0) - strncpy(gcd->netmask, + l_strlcpy(gcd->netmask, &ip_mask[strlen(gcd->address) + 1], sizeof(gcd->netmask)); - strncpy(gcd->gateway, gw, sizeof(gcd->gateway)); - strncpy(gcd->dns1, dns1, sizeof(gcd->dns1)); - strncpy(gcd->dns2, dns2, sizeof(gcd->dns2)); + l_strlcpy(gcd->gateway, gw, sizeof(gcd->gateway)); + l_strlcpy(gcd->dns1, dns1, sizeof(gcd->dns1)); + l_strlcpy(gcd->dns2, dns2, sizeof(gcd->dns2)); } } @@ -229,7 +230,7 @@ static void address_cb(gboolean ok, GAtResult *result, gpointer user_data) if (!g_at_result_iter_next_string(&iter, &address)) goto error; - strncpy(gcd->address, address, sizeof(gcd->address)); + l_strlcpy(gcd->address, address, sizeof(gcd->address)); sprintf(buf, "AT+CGCONTRDP=%d", gcd->active_context); if (g_at_chat_send(gcd->chat, buf, cgcontrdp_prefix,