summaryrefslogtreecommitdiff
path: root/libnm-core
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2018-02-21 18:35:43 +0100
committerThomas Haller <thaller@redhat.com>2018-03-03 16:57:42 +0100
commit3d6a2b8d6b1a7e2b6cf1053f3d635e9d934f64fc (patch)
treed1c5505a4a5f89543a7924c12ad742ea0c5be52a /libnm-core
parent608dfacb0bddfa2a50da663db318b0ff0df0f6b1 (diff)
downloadNetworkManager-3d6a2b8d6b1a7e2b6cf1053f3d635e9d934f64fc.tar.gz
libnm/keyfile/trivial: rename local variables in preparation of refactoring
Diffstat (limited to 'libnm-core')
-rw-r--r--libnm-core/nm-keyfile-reader.c76
1 files changed, 38 insertions, 38 deletions
diff --git a/libnm-core/nm-keyfile-reader.c b/libnm-core/nm-keyfile-reader.c
index f850638497..585e159d9a 100644
--- a/libnm-core/nm-keyfile-reader.c
+++ b/libnm-core/nm-keyfile-reader.c
@@ -993,79 +993,79 @@ has_cert_ext (const char *path)
static gboolean
handle_as_scheme (KeyfileReaderInfo *info, GBytes *bytes, NMSetting *setting, const char *key)
{
- const char *data;
- gsize data_len, bin_len;
+ const char *bin;
+ gsize bin_len0, bin_decoded_len;
- data = g_bytes_get_data (bytes, &data_len);
+ bin = g_bytes_get_data (bytes, &bin_len0);
- g_return_val_if_fail (data && data_len > 0, FALSE);
+ g_return_val_if_fail (bin && bin_len0 > 0, FALSE);
- /* to be a scheme, @data must be a zero terminated string, which is counted by @data_len */
- if (data[data_len - 1] != '\0')
+ /* to be a scheme, @bin must be a zero terminated string, which is counted by @bin_len0 */
+ if (bin[bin_len0 - 1] != '\0')
return FALSE;
- data_len--;
+ bin_len0--;
/* It's the PATH scheme, can just set plain data.
- * In this case, @data_len includes */
- if ( data_len >= NM_STRLEN (NM_KEYFILE_CERT_SCHEME_PREFIX_PATH)
- && g_str_has_prefix (data, NM_KEYFILE_CERT_SCHEME_PREFIX_PATH)) {
- if (nm_setting_802_1x_check_cert_scheme (data, data_len + 1, NULL) == NM_SETTING_802_1X_CK_SCHEME_PATH) {
- const char *path = &data[NM_STRLEN (NM_KEYFILE_CERT_SCHEME_PREFIX_PATH)];
- gs_free char *path_free = NULL;
-
- if (path[0] != '/') {
+ * In this case, @bin_len0 includes */
+ if ( bin_len0 >= NM_STRLEN (NM_KEYFILE_CERT_SCHEME_PREFIX_PATH)
+ && g_str_has_prefix (bin, NM_KEYFILE_CERT_SCHEME_PREFIX_PATH)) {
+ if (nm_setting_802_1x_check_cert_scheme (bin, bin_len0 + 1, NULL) == NM_SETTING_802_1X_CK_SCHEME_PATH) {
+ const char *path2 = &bin[NM_STRLEN (NM_KEYFILE_CERT_SCHEME_PREFIX_PATH)];
+ gs_free char *path2_free = NULL;
+
+ if (path2[0] != '/') {
/* we want to read absolute paths because we use keyfile as exchange
* between different processes which might not have the same cwd. */
- path = path_free = get_cert_path (info->base_dir, (const guint8 *) path,
- data_len - NM_STRLEN (NM_KEYFILE_CERT_SCHEME_PREFIX_PATH));
+ path2 = path2_free = get_cert_path (info->base_dir, (const guint8 *) path2,
+ bin_len0 - NM_STRLEN (NM_KEYFILE_CERT_SCHEME_PREFIX_PATH));
}
g_object_set (setting, key, bytes, NULL);
- if (!g_file_test (path, G_FILE_TEST_EXISTS)) {
+ if (!g_file_test (path2, G_FILE_TEST_EXISTS)) {
handle_warn (info, key, NM_KEYFILE_WARN_SEVERITY_INFO_MISSING_FILE,
_("certificate or key file '%s' does not exist"),
- path);
+ path2);
}
} else {
handle_warn (info, key, NM_KEYFILE_WARN_SEVERITY_WARN,
- _("invalid key/cert value path \"%s\""), data);
+ _("invalid key/cert value path \"%s\""), bin);
}
return TRUE;
}
- if ( data_len >= NM_STRLEN (NM_KEYFILE_CERT_SCHEME_PREFIX_PKCS11)
- && g_str_has_prefix (data, NM_KEYFILE_CERT_SCHEME_PREFIX_PKCS11)) {
- if (nm_setting_802_1x_check_cert_scheme (data, data_len + 1, NULL) == NM_SETTING_802_1X_CK_SCHEME_PKCS11) {
+ if ( bin_len0 >= NM_STRLEN (NM_KEYFILE_CERT_SCHEME_PREFIX_PKCS11)
+ && g_str_has_prefix (bin, NM_KEYFILE_CERT_SCHEME_PREFIX_PKCS11)) {
+ if (nm_setting_802_1x_check_cert_scheme (bin, bin_len0 + 1, NULL) == NM_SETTING_802_1X_CK_SCHEME_PKCS11) {
g_object_set (setting, key, bytes, NULL);
} else {
handle_warn (info, key, NM_KEYFILE_WARN_SEVERITY_WARN,
- _("invalid PKCS#11 URI \"%s\""), data);
+ _("invalid PKCS#11 URI \"%s\""), bin);
}
return TRUE;
}
- if ( data_len > NM_STRLEN (NM_KEYFILE_CERT_SCHEME_PREFIX_BLOB)
- && g_str_has_prefix (data, NM_KEYFILE_CERT_SCHEME_PREFIX_BLOB)) {
- const char *cdata = data + NM_STRLEN (NM_KEYFILE_CERT_SCHEME_PREFIX_BLOB);
- guchar *bin;
+ if ( bin_len0 > NM_STRLEN (NM_KEYFILE_CERT_SCHEME_PREFIX_BLOB)
+ && g_str_has_prefix (bin, NM_KEYFILE_CERT_SCHEME_PREFIX_BLOB)) {
+ const char *cdata = bin + NM_STRLEN (NM_KEYFILE_CERT_SCHEME_PREFIX_BLOB);
+ guchar *bin_decoded;
GBytes *bytes2;
gsize i;
gboolean valid_base64;
- data_len -= NM_STRLEN (NM_KEYFILE_CERT_SCHEME_PREFIX_BLOB);
+ bin_len0 -= NM_STRLEN (NM_KEYFILE_CERT_SCHEME_PREFIX_BLOB);
/* Let's be strict here. We expect valid base64, no funny stuff!!
* We didn't write such invalid data ourselfes and refuse to read it as blob. */
- if ((valid_base64 = (data_len % 4 == 0))) {
- for (i = 0; i < data_len; i++) {
+ if ((valid_base64 = (bin_len0 % 4 == 0))) {
+ for (i = 0; i < bin_len0; i++) {
char c = cdata[i];
if (!( (c >= 'a' && c <= 'z')
|| (c >= 'A' && c <= 'Z')
|| (c >= '0' && c <= '9')
|| (c == '+' || c == '/'))) {
- if (c != '=' || i < data_len - 2)
+ if (c != '=' || i < bin_len0 - 2)
valid_base64 = FALSE;
else {
- for (; i < data_len; i++) {
+ for (; i < bin_len0; i++) {
if (cdata[i] != '=')
valid_base64 = FALSE;
}
@@ -1080,18 +1080,18 @@ handle_as_scheme (KeyfileReaderInfo *info, GBytes *bytes, NMSetting *setting, co
return TRUE;
}
- bin = g_base64_decode (cdata, &bin_len);
+ bin_decoded = g_base64_decode (cdata, &bin_decoded_len);
- g_return_val_if_fail (bin_len > 0, FALSE);
- if (nm_setting_802_1x_check_cert_scheme (bin, bin_len, NULL) != NM_SETTING_802_1X_CK_SCHEME_BLOB) {
+ g_return_val_if_fail (bin_decoded_len > 0, FALSE);
+ if (nm_setting_802_1x_check_cert_scheme (bin_decoded, bin_decoded_len, NULL) != NM_SETTING_802_1X_CK_SCHEME_BLOB) {
/* The blob probably starts with "file://". Setting the cert data will confuse NMSetting8021x.
* In fact this is a limitation of NMSetting8021x which does not support setting blobs that start
* with file://. Just warn and return TRUE to signal that we ~handled~ the setting. */
- g_free (bin);
+ g_free (bin_decoded);
handle_warn (info, key, NM_KEYFILE_WARN_SEVERITY_WARN,
_("invalid key/cert value data:;base64,file://"));
} else {
- bytes2 = g_bytes_new_take (bin, bin_len);
+ bytes2 = g_bytes_new_take (bin_decoded, bin_decoded_len);
g_object_set (setting, key, bytes2, NULL);
g_bytes_unref (bytes2);
}