diff options
-rw-r--r-- | libpam/include/pam_cc_compat.h | 6 | ||||
-rw-r--r-- | modules/pam_namespace/md5.c | 6 | ||||
-rw-r--r-- | modules/pam_namespace/md5.h | 4 | ||||
-rw-r--r-- | modules/pam_timestamp/sha1.h | 3 | ||||
-rw-r--r-- | modules/pam_unix/md5.c | 7 | ||||
-rw-r--r-- | modules/pam_unix/md5.h | 4 |
6 files changed, 23 insertions, 7 deletions
diff --git a/libpam/include/pam_cc_compat.h b/libpam/include/pam_cc_compat.h index a4b84c62..d4c905df 100644 --- a/libpam/include/pam_cc_compat.h +++ b/libpam/include/pam_cc_compat.h @@ -15,6 +15,12 @@ # define PAM_CLANG_PREREQ(maj, min) 0 #endif +#if PAM_GNUC_PREREQ(2, 7) +# define PAM_ATTRIBUTE_ALIGNED(arg) __attribute__((__aligned__(arg))) +#else +# define PAM_ATTRIBUTE_ALIGNED(arg) /* empty */ +#endif + #if PAM_GNUC_PREREQ(4, 6) # define DIAG_PUSH_IGNORE_CAST_QUAL \ _Pragma("GCC diagnostic push"); \ diff --git a/modules/pam_namespace/md5.c b/modules/pam_namespace/md5.c index dc95ab14..b9a7f084 100644 --- a/modules/pam_namespace/md5.c +++ b/modules/pam_namespace/md5.c @@ -26,12 +26,14 @@ #if defined(__i386) || defined(__i386__) || defined(__x86_64) || defined(__x86_64__) #define byteReverse(buf, len) /* Nothing */ #else -static void byteReverse(unsigned char *buf, unsigned longs); +typedef unsigned char PAM_ATTRIBUTE_ALIGNED(4) uint8_aligned; + +static void byteReverse(uint8_aligned *buf, unsigned longs); /* * Note: this code is harmless on little-endian machines. */ -static void byteReverse(unsigned char *buf, unsigned longs) +static void byteReverse(uint8_aligned *buf, unsigned longs) { uint32 t; do { diff --git a/modules/pam_namespace/md5.h b/modules/pam_namespace/md5.h index 73f85833..bded3302 100644 --- a/modules/pam_namespace/md5.h +++ b/modules/pam_namespace/md5.h @@ -2,12 +2,14 @@ #ifndef MD5_H #define MD5_H +#include "pam_cc_compat.h" + typedef unsigned int uint32; struct MD5Context { uint32 buf[4]; uint32 bits[2]; - unsigned char in[64]; + unsigned char in[64] PAM_ATTRIBUTE_ALIGNED(4); }; #define MD5_DIGEST_LENGTH 16 diff --git a/modules/pam_timestamp/sha1.h b/modules/pam_timestamp/sha1.h index a445e4e6..a1c38917 100644 --- a/modules/pam_timestamp/sha1.h +++ b/modules/pam_timestamp/sha1.h @@ -40,12 +40,13 @@ #include <stdint.h> #include <sys/types.h> +#include "pam_cc_compat.h" #define SHA1_BLOCK_SIZE 64 struct sha1_context { size_t count; - unsigned char pending[SHA1_BLOCK_SIZE]; + unsigned char pending[SHA1_BLOCK_SIZE] PAM_ATTRIBUTE_ALIGNED(4); uint32_t counts[2]; size_t pending_count; uint32_t a, b, c, d, e; diff --git a/modules/pam_unix/md5.c b/modules/pam_unix/md5.c index 94f0485b..9954536f 100644 --- a/modules/pam_unix/md5.c +++ b/modules/pam_unix/md5.c @@ -24,13 +24,16 @@ #ifndef HIGHFIRST #define byteReverse(buf, len) /* Nothing */ #else -static void byteReverse(unsigned char *buf, unsigned longs); + +typedef unsigned char PAM_ATTRIBUTE_ALIGNED(4) uint8_aligned; + +static void byteReverse(uint8_aligned *buf, unsigned longs); #ifndef ASM_MD5 /* * Note: this code is harmless on little-endian machines. */ -static void byteReverse(unsigned char *buf, unsigned longs) +static void byteReverse(uint8_aligned *buf, unsigned longs) { uint32 t; do { diff --git a/modules/pam_unix/md5.h b/modules/pam_unix/md5.h index 103f168a..d9186b7f 100644 --- a/modules/pam_unix/md5.h +++ b/modules/pam_unix/md5.h @@ -2,12 +2,14 @@ #ifndef MD5_H #define MD5_H +#include "pam_cc_compat.h" + typedef unsigned int uint32; struct MD5Context { uint32 buf[4]; uint32 bits[2]; - unsigned char in[64]; + unsigned char in[64] PAM_ATTRIBUTE_ALIGNED(4); }; void GoodMD5Init(struct MD5Context *); |