Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/crypto/external/bsd/netpgp/dist/src/netpgpverify Avoid undef...
details: https://anonhg.NetBSD.org/src/rev/9b34b0e1bcc0
branches: trunk
changeset: 834070:9b34b0e1bcc0
user: kamil <kamil%NetBSD.org@localhost>
date: Thu Jul 26 00:26:45 2018 +0000
description:
Avoid undefined behavior in netpgpverify
Do not change the signedness bit with a left shift operation.
Cast to unsigned integer to prevent this.
pgpsum.c:187:18, left shift of 130 by 24 places cannot be represented in type 'int'
Detected with micro-UBSan in the user mode.
diffstat:
crypto/external/bsd/netpgp/dist/src/netpgpverify/pgpsum.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diffs (21 lines):
diff -r dff33dad16e2 -r 9b34b0e1bcc0 crypto/external/bsd/netpgp/dist/src/netpgpverify/pgpsum.c
--- a/crypto/external/bsd/netpgp/dist/src/netpgpverify/pgpsum.c Thu Jul 26 00:20:41 2018 +0000
+++ b/crypto/external/bsd/netpgp/dist/src/netpgpverify/pgpsum.c Thu Jul 26 00:26:45 2018 +0000
@@ -175,7 +175,7 @@
u16 u;
u.i16 = in;
- return (u.i8[0] << 8) | u.i8[1];
+ return ((uint16_t)u.i8[0] << 8) | u.i8[1];
}
static inline uint32_t
@@ -184,7 +184,7 @@
u32 u;
u.i32 = in;
- return (u.i8[0] << 24) | (u.i8[1] << 16) | (u.i8[2] << 8) | u.i8[3];
+ return ((uint32_t)u.i8[0] << 24) | (u.i8[1] << 16) | (u.i8[2] << 8) | u.i8[3];
}
static inline int
Home |
Main Index |
Thread Index |
Old Index