Module Name: src Committed By: kamil Date: Sat Feb 22 10:22:32 UTC 2020
Modified Files: src/lib/libcrypt: crypt.c Log Message: Avoid undefined behavior in bit shift operations crypt.c:839:40, left shift of negative value -1197182952 crypt.c:840:40, left shift of negative value -264997776 To generate a diff of this commit: cvs rdiff -u -r1.36 -r1.37 src/lib/libcrypt/crypt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/lib/libcrypt/crypt.c diff -u src/lib/libcrypt/crypt.c:1.36 src/lib/libcrypt/crypt.c:1.37 --- src/lib/libcrypt/crypt.c:1.36 Mon Oct 21 02:36:48 2019 +++ src/lib/libcrypt/crypt.c Sat Feb 22 10:22:32 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: crypt.c,v 1.36 2019/10/21 02:36:48 jhigh Exp $ */ +/* $NetBSD: crypt.c,v 1.37 2020/02/22 10:22:32 kamil Exp $ */ /* * Copyright (c) 1989, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)crypt.c 8.1.1.1 (Berkeley) 8/18/93"; #else -__RCSID("$NetBSD: crypt.c,v 1.36 2019/10/21 02:36:48 jhigh Exp $"); +__RCSID("$NetBSD: crypt.c,v 1.37 2020/02/22 10:22:32 kamil Exp $"); #endif #endif /* not lint */ @@ -836,8 +836,8 @@ des_cipher(const char *in, char *out, lo } /* store the encrypted (or decrypted) result */ - L0 = ((L0 >> 3) & 0x0f0f0f0fL) | ((L1 << 1) & 0xf0f0f0f0L); - L1 = ((R0 >> 3) & 0x0f0f0f0fL) | ((R1 << 1) & 0xf0f0f0f0L); + L0 = (((uint32_t)L0 >> 3) & 0x0f0f0f0fL) | (((uint32_t)L1 << 1) & 0xf0f0f0f0L); + L1 = (((uint32_t)R0 >> 3) & 0x0f0f0f0fL) | (((uint32_t)R1 << 1) & 0xf0f0f0f0L); STORE(L,L0,L1,B); PERM6464(L,L0,L1,B.b, (C_block *)CF6464); #if defined(MUST_ALIGN)