diff --git a/libraries/liblutil/passwd.c b/libraries/liblutil/passwd.c index 9aabb86a85..4d12404e66 100644 --- a/libraries/liblutil/passwd.c +++ b/libraries/liblutil/passwd.c @@ -682,18 +682,21 @@ static int chk_md5( */ static void lmPasswd_to_key( - const unsigned char *lmPasswd, + const char *lmPasswd, des_cblock *key) { + const unsigned char *lpw = (const unsigned char *) lmPasswd; + unsigned char *k = (unsigned char *) key; + /* make room for parity bits */ - ((char *)key)[0] = lmPasswd[0]; - ((char *)key)[1] = ((lmPasswd[0]&0x01)<<7) | (lmPasswd[1]>>1); - ((char *)key)[2] = ((lmPasswd[1]&0x03)<<6) | (lmPasswd[2]>>2); - ((char *)key)[3] = ((lmPasswd[2]&0x07)<<5) | (lmPasswd[3]>>3); - ((char *)key)[4] = ((lmPasswd[3]&0x0F)<<4) | (lmPasswd[4]>>4); - ((char *)key)[5] = ((lmPasswd[4]&0x1F)<<3) | (lmPasswd[5]>>5); - ((char *)key)[6] = ((lmPasswd[5]&0x3F)<<2) | (lmPasswd[6]>>6); - ((char *)key)[7] = ((lmPasswd[6]&0x7F)<<1); + k[0] = lpw[0]; + k[1] = ((lpw[0] & 0x01) << 7) | (lpw[1] >> 1); + k[2] = ((lpw[1] & 0x03) << 6) | (lpw[2] >> 2); + k[3] = ((lpw[2] & 0x07) << 5) | (lpw[3] >> 3); + k[4] = ((lpw[3] & 0x0F) << 4) | (lpw[4] >> 4); + k[5] = ((lpw[4] & 0x1F) << 3) | (lpw[5] >> 5); + k[6] = ((lpw[5] & 0x3F) << 2) | (lpw[6] >> 6); + k[7] = ((lpw[6] & 0x7F) << 1); des_set_odd_parity( key ); }