summaryrefslogtreecommitdiff
path: root/src/ppp
diff options
context:
space:
mode:
authorLubomir Rintel <lkundrak@v3.sk>2018-02-12 17:42:25 +0000
committerLubomir Rintel <lkundrak@v3.sk>2018-02-12 20:46:47 +0100
commit85c0dc4a92f036df7e332e8c4deaaae78575e294 (patch)
treeaf42e499696f61f8bb9c52bbeeaf19daf6c985f6 /src/ppp
parent7f847d71f39c692b3205774ccccc5aebada5fd0c (diff)
downloadNetworkManager-85c0dc4a92f036df7e332e8c4deaaae78575e294.tar.gz
ppp/plugin: use g_strlcpy()
It's nicer but also doesn't annoy gcc 8: "error: ‘strncpy’ specified bound depends on the length of the source argument [-Werror=stringop-overflow=]"
Diffstat (limited to 'src/ppp')
-rw-r--r--src/ppp/nm-pppd-plugin.c19
1 files changed, 4 insertions, 15 deletions
diff --git a/src/ppp/nm-pppd-plugin.c b/src/ppp/nm-pppd-plugin.c
index e3df26ef08..989f74339d 100644
--- a/src/ppp/nm-pppd-plugin.c
+++ b/src/ppp/nm-pppd-plugin.c
@@ -311,7 +311,6 @@ get_credentials (char *username, char *password)
{
const char *my_username = NULL;
const char *my_password = NULL;
- size_t len;
GVariant *ret;
GError *err = NULL;
@@ -343,21 +342,11 @@ get_credentials (char *username, char *password)
g_variant_get (ret, "(&s&s)", &my_username, &my_password);
- if (my_username) {
- len = strlen (my_username) + 1;
- len = len < MAXNAMELEN ? len : MAXNAMELEN;
+ if (my_username)
+ g_strlcpy (username, my_username, MAXNAMELEN);
- strncpy (username, my_username, len);
- username[len - 1] = '\0';
- }
-
- if (my_password) {
- len = strlen (my_password) + 1;
- len = len < MAXSECRETLEN ? len : MAXSECRETLEN;
-
- strncpy (password, my_password, len);
- password[len - 1] = '\0';
- }
+ if (my_password)
+ g_strlcpy (password, my_password, MAXSECRETLEN);
g_variant_unref (ret);