diff options
| author | Michael Biebl <biebl@debian.org> | 2023-02-10 11:51:50 +0100 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2023-02-10 11:51:50 +0100 |
| commit | 58dddb802071d967ff5731f3333239ead78248e8 (patch) | |
| tree | def9e578e4786f8cbc56ce1b6cabf7670e00ae81 /src/libnm-crypto | |
| parent | 2c1b7a7ea3c332b4d690c0595ef76c81de1f0cc8 (diff) | |
| parent | 1372848511cb896b80b51ed1a3e9606bd9816631 (diff) | |
Update upstream source from tag 'upstream/1.42.0'
Update to upstream version '1.42.0' with Debian dir 2b9fa2718b2bd34fa58008e335a0d81b87ad57cf
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 |