summaryrefslogtreecommitdiff
path: root/libnm-util
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2018-08-31 10:59:31 +0200
committerThomas Haller <thaller@redhat.com>2018-09-04 07:38:30 +0200
commit08c80dd2e32d4b50786c8c8fd5308e513c1bc90d (patch)
tree06a762143a05fc5adf2d3fbe77a28400e95a73d9 /libnm-util
parent858d5c3e917a60f076c80873149a911c0dc2f497 (diff)
downloadNetworkManager-08c80dd2e32d4b50786c8c8fd5308e513c1bc90d.tar.gz
libnm/crypto: rework endianness detection for crypto_verify_pkcs12()
At other places, we already use __BYTE_ORDER define to detect endianness. We don't need multiple mechanisms. Also note that meson did not do the correct thing as AC_C_BIGENDIAN, so meson + nss + big-endian was possibly broken.
Diffstat (limited to 'libnm-util')
-rw-r--r--libnm-util/crypto_nss.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/libnm-util/crypto_nss.c b/libnm-util/crypto_nss.c
index 5736db4f89..01bb28c33d 100644
--- a/libnm-util/crypto_nss.c
+++ b/libnm-util/crypto_nss.c
@@ -442,9 +442,6 @@ crypto_verify_pkcs12 (const GByteArray *data,
SECStatus s;
char *ucs2_password;
long ucs2_chars = 0;
-#ifndef WORDS_BIGENDIAN
- guint16 *p;
-#endif /* WORDS_BIGENDIAN */
if (error)
g_return_val_if_fail (*error == NULL, FALSE);
@@ -470,10 +467,14 @@ crypto_verify_pkcs12 (const GByteArray *data,
memset (ucs2_password, 0, ucs2_chars);
g_free (ucs2_password);
-#ifndef WORDS_BIGENDIAN
- for (p = (guint16 *) pw.data; p < (guint16 *) (pw.data + pw.len); p++)
- *p = GUINT16_SWAP_LE_BE (*p);
-#endif /* WORDS_BIGENDIAN */
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+ {
+ guint16 *p;
+
+ for (p = (guint16 *) pw.data; p < (guint16 *) (pw.data + pw.len); p++)
+ *p = GUINT16_SWAP_LE_BE (*p);
+ }
+#endif
} else {
/* NULL password */
pw.data = NULL;