diff options
| author | Michael Biebl <biebl@debian.org> | 2023-02-10 11:50:34 +0100 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2023-02-10 11:50:34 +0100 |
| commit | 1372848511cb896b80b51ed1a3e9606bd9816631 (patch) | |
| tree | 674792b9385bdef935988894b45f06b2af39f88c /src/libnm-crypto | |
| parent | 40ec077ea305994c1fc2130add6787ca0c73e2c6 (diff) | |
New upstream version 1.42.0 upstream/1.42.0
Diffstat (limited to 'src/libnm-crypto')
| -rw-r--r-- | src/libnm-crypto/nm-crypto-nss.c | 13 |
1 files changed, 10 insertions, 3 deletions
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 |