diff options
author | rob <rob@openbsd.org> | 2019-04-27 14:58:14 +0000 |
---|---|---|
committer | rob <rob@openbsd.org> | 2019-04-27 14:58:14 +0000 |
commit | b7b4e415689c3ad60f35b34849a250396d1574a9 (patch) | |
tree | 971bc4691c68b0dff64a854a4317a23af46f88a2 /usr.sbin/ldapd | |
parent | Add test, update comments, and modify some output. (diff) | |
download | wireguard-openbsd-b7b4e415689c3ad60f35b34849a250396d1574a9.tar.xz wireguard-openbsd-b7b4e415689c3ad60f35b34849a250396d1574a9.zip |
Only apply sign extension when less than eight bytes have been consumed. This
fixes a problem when handling large negative integers.
ok claudio@
Diffstat (limited to 'usr.sbin/ldapd')
-rw-r--r-- | usr.sbin/ldapd/ber.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/usr.sbin/ldapd/ber.c b/usr.sbin/ldapd/ber.c index 86a5aeb3de8..bc32578965c 100644 --- a/usr.sbin/ldapd/ber.c +++ b/usr.sbin/ldapd/ber.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ber.c,v 1.31 2018/11/27 12:09:38 martijn Exp $ */ +/* $OpenBSD: ber.c,v 1.32 2019/04/27 14:58:14 rob Exp $ */ /* * Copyright (c) 2007, 2012 Reyk Floeter <reyk@openbsd.org> @@ -1240,8 +1240,9 @@ ber_read_element(struct ber *ber, struct ber_element *elm) } /* sign extend if MSB is set */ - if (val >> ((i - 1) * 8) & 0x80) - val |= ULLONG_MAX << (i * 8); + if (len < (ssize_t)sizeof(long long) && + (val >> ((len - 1) * 8) & 0x80)) + val |= ULLONG_MAX << (len * 8); elm->be_numeric = val; break; case BER_TYPE_BITSTRING: |