--- contrib/pgcrypto/crypt-gensalt.c +++ contrib/pgcrypto/crypt-gensalt.c @@ -69,9 +69,9 @@ output[2] = _crypt_itoa64[(count >> 6) & 0x3f]; output[3] = _crypt_itoa64[(count >> 12) & 0x3f]; output[4] = _crypt_itoa64[(count >> 18) & 0x3f]; - value = (unsigned long) input[0] | - ((unsigned long) input[1] << 8) | - ((unsigned long) input[2] << 16); + value = (unsigned long) (input[0] & 0xFF) | + ((unsigned long) (input[1] & 0xFF) << 8) | + ((unsigned long) (input[2] & 0xFF) << 16); output[5] = _crypt_itoa64[value & 0x3f]; output[6] = _crypt_itoa64[(value >> 6) & 0x3f]; output[7] = _crypt_itoa64[(value >> 12) & 0x3f]; @@ -98,9 +98,9 @@ output[0] = '$'; output[1] = '1'; output[2] = '$'; - value = (unsigned long) input[0] | - ((unsigned long) input[1] << 8) | - ((unsigned long) input[2] << 16); + value = (unsigned long) (input[0] & 0xFF) | + ((unsigned long) (input[1] & 0xFF) << 8) | + ((unsigned long) (input[2] & 0xFF) << 16); output[3] = _crypt_itoa64[value & 0x3f]; output[4] = _crypt_itoa64[(value >> 6) & 0x3f]; output[5] = _crypt_itoa64[(value >> 12) & 0x3f]; @@ -109,9 +109,9 @@ if (size >= 6 && output_size >= 3 + 4 + 4 + 1) { - value = (unsigned long) input[3] | - ((unsigned long) input[4] << 8) | - ((unsigned long) input[5] << 16); + value = (unsigned long) (input[3] & 0xFF) | + ((unsigned long) (input[4] & 0xFF) << 8) | + ((unsigned long) (input[5] & 0xFF) << 16); output[7] = _crypt_itoa64[value & 0x3f]; output[8] = _crypt_itoa64[(value >> 6) & 0x3f]; output[9] = _crypt_itoa64[(value >> 12) & 0x3f];