From 1372848511cb896b80b51ed1a3e9606bd9816631 Mon Sep 17 00:00:00 2001 From: Michael Biebl Date: Fri, 10 Feb 2023 11:50:34 +0100 Subject: New upstream version 1.42.0 --- src/libnm-crypto/nm-crypto-nss.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src/libnm-crypto') diff --git a/src/libnm-crypto/nm-crypto-nss.c b/src/libnm-crypto/nm-crypto-nss.c index b31ca55e..6ac52b2c 100644 --- a/src/libnm-crypto/nm-crypto-nss.c +++ b/src/libnm-crypto/nm-crypto-nss.c @@ -450,10 +450,17 @@ _nm_crypto_verify_pkcs12(const guint8 *data, gsize data_len, const char *passwor #if __BYTE_ORDER == __LITTLE_ENDIAN { - guint16 *p, *p_end; + const guint16 *p_end; + guint16 *p; - p_end = (guint16 *) &(((guint8 *) pw.data)[ucs2_password.len]); - for (p = (guint16 *) pw.data; p < p_end; p++) + /* we cast here to guint16 pointers (which would trigger a "-Wcast-align"). + * But this is safe, because ucs2_password.len is a multiple of 2 and + * because pw.data was an allocated buffer (that is presumably aligned + * correctly). */ + nm_assert(ucs2_password.len % 2 == 0); + + p_end = NM_CAST_ALIGN(guint16, &(((guint8 *) pw.data)[ucs2_password.len])); + for (p = NM_CAST_ALIGN(guint16, pw.data); p < p_end; p++) *p = GUINT16_SWAP_LE_BE(*p); } #endif -- cgit 1.3.0-6-gf8a5