diff options
author | Thomas Haller <thaller@redhat.com> | 2015-02-26 02:27:54 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2015-03-12 18:12:25 +0100 |
commit | 11371b5470a890512b697d0926a242d9aefe9d1d (patch) | |
tree | d8029a0122f651989b5236e742b004b024f437df /libnm-core/nm-setting-8021x.c | |
parent | 88a79625a667a562831925d4636bf819e0aa0f6b (diff) | |
download | NetworkManager-11371b5470a890512b697d0926a242d9aefe9d1d.tar.gz |
libnm: only call strlen() once in NMSetting8021x:path_to_scheme_value()
Also assert that path is not empty.
Diffstat (limited to 'libnm-core/nm-setting-8021x.c')
-rw-r--r-- | libnm-core/nm-setting-8021x.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/libnm-core/nm-setting-8021x.c b/libnm-core/nm-setting-8021x.c index 10d29d980f..a02e7114d5 100644 --- a/libnm-core/nm-setting-8021x.c +++ b/libnm-core/nm-setting-8021x.c @@ -572,13 +572,16 @@ static GBytes * path_to_scheme_value (const char *path) { GByteArray *array; + gsize len; - g_return_val_if_fail (path != NULL, NULL); + g_return_val_if_fail (path != NULL && path[0], NULL); - /* Add the path scheme tag to the front, then the fielname */ - array = g_byte_array_sized_new (strlen (path) + strlen (SCHEME_PATH) + 1); + len = strlen (path); + + /* Add the path scheme tag to the front, then the filename */ + array = g_byte_array_sized_new (len + strlen (SCHEME_PATH) + 1); g_byte_array_append (array, (const guint8 *) SCHEME_PATH, strlen (SCHEME_PATH)); - g_byte_array_append (array, (const guint8 *) path, strlen (path)); + g_byte_array_append (array, (const guint8 *) path, len); g_byte_array_append (array, (const guint8 *) "\0", 1); return g_byte_array_free_to_bytes (array); |