diff options
author | Tom Lane | 2001-10-15 19:15:18 +0000 |
---|---|---|
committer | Tom Lane | 2001-10-15 19:15:18 +0000 |
commit | 77f27d5ec36584addbbad0239d31753240e44001 (patch) | |
tree | bb10398a8c365adb7ecb79df35b06b87560381b2 /contrib/pgcrypto/crypt-des.c | |
parent | aa6970efff0569801f7d09235fdd193ebaee62d7 (diff) |
Fix some portability problems (get it to compile, at least, on HP's cc)
Diffstat (limited to 'contrib/pgcrypto/crypt-des.c')
-rw-r--r-- | contrib/pgcrypto/crypt-des.c | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/contrib/pgcrypto/crypt-des.c b/contrib/pgcrypto/crypt-des.c index d9e12127b77..de6b1865e37 100644 --- a/contrib/pgcrypto/crypt-des.c +++ b/contrib/pgcrypto/crypt-des.c @@ -58,18 +58,13 @@ * alignment). */ -#include <postgres.h> +#include "postgres.h" + #include "px-crypt.h" /* for ntohl/htonl */ #include <netinet/in.h> - -/* We can't always assume gcc */ -#ifdef __GNUC__ -#define INLINE inline -#endif - #define _PASSWORD_EFMT1 '_' static uint8 IP[64] = { @@ -200,7 +195,7 @@ static uint32 comp_maskl[8][128], static uint32 old_rawkey0, old_rawkey1; -static INLINE int +static inline int ascii_to_bin(char ch) { if (ch > 'z') @@ -611,6 +606,7 @@ do_des(uint32 l_in, uint32 r_in, uint32 * l_out, uint32 * r_out, int count) static int des_cipher(const char *in, char *out, long salt, int count) { + uint32 buffer[2]; uint32 l_out, r_out, rawl, @@ -622,13 +618,20 @@ des_cipher(const char *in, char *out, long salt, int count) setup_salt(salt); - rawl = ntohl(*((uint32 *) in)++); - rawr = ntohl(*((uint32 *) in)); + /* copy data to avoid assuming input is word-aligned */ + memcpy(buffer, in, sizeof(buffer)); + + rawl = ntohl(buffer[0]); + rawr = ntohl(buffer[1]); retval = do_des(rawl, rawr, &l_out, &r_out, count); - *((uint32 *) out)++ = htonl(l_out); - *((uint32 *) out) = htonl(r_out); + buffer[0] = htonl(l_out); + buffer[1] = htonl(r_out); + + /* copy data to avoid assuming output is word-aligned */ + memcpy(out, buffer, sizeof(buffer)); + return (retval); } |