summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libnm-core/nm-setting-8021x.c11
-rw-r--r--libnm-util/nm-setting-8021x.c12
2 files changed, 14 insertions, 9 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);
diff --git a/libnm-util/nm-setting-8021x.c b/libnm-util/nm-setting-8021x.c
index 456d5eee68..1dc768c210 100644
--- a/libnm-util/nm-setting-8021x.c
+++ b/libnm-util/nm-setting-8021x.c
@@ -551,14 +551,16 @@ static GByteArray *
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);
- g_assert (array);
+ 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 array;
}