diff options
author | rob <rob@cvs.openbsd.org> | 2018-07-04 13:04:31 +0000 |
---|---|---|
committer | rob <rob@cvs.openbsd.org> | 2018-07-04 13:04:31 +0000 |
commit | e795d3a8301f34df24bdb19ea6c73d25141047e9 (patch) | |
tree | c7434e15d70df066093a1df79614493975913ee6 /usr.bin | |
parent | 47298fa5c4ae762cbba0aa53519237aa54917ccb (diff) |
Relocate the update of br_offs from ber_read() to ber_readbuf() so ber_getc()
can call ber_readbuf() in all cases. This resolves a problem previously
encountered with SNMPv3 authentication, simplifies the code, and completes a
full synchronization of all ber instances.
Proposed by claudio@. Problematic use case in snmpd tested by sthen@ and me.
ldap(s) appear happy as well.
looks good to claudio@
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/ldap/ber.c | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/usr.bin/ldap/ber.c b/usr.bin/ldap/ber.c index 264fd4e5410..0b26ef8e9ba 100644 --- a/usr.bin/ldap/ber.c +++ b/usr.bin/ldap/ber.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ber.c,v 1.8 2018/07/03 18:49:10 rob Exp $ */ +/* $OpenBSD: ber.c,v 1.9 2018/07/04 13:04:30 rob Exp $ */ /* * Copyright (c) 2007, 2012 Reyk Floeter <reyk@openbsd.org> @@ -1212,8 +1212,7 @@ ber_read_element(struct ber *ber, struct ber_element *elm) static ssize_t ber_readbuf(struct ber *b, void *buf, size_t nbytes) { - size_t sz; - size_t len; + size_t sz, len; if (b->br_rbuf == NULL) return -1; @@ -1227,6 +1226,7 @@ ber_readbuf(struct ber *b, void *buf, size_t nbytes) bcopy(b->br_rptr, buf, len); b->br_rptr += len; + b->br_offs += len; return (len); } @@ -1284,14 +1284,10 @@ ber_read(struct ber *ber, void *buf, size_t len) r = ber_readbuf(ber, b, remain); if (r == -1) return -1; - if (r == 0) - return (b - (u_char *)buf); b += r; remain -= r; } - r = b - (u_char *)buf; - ber->br_offs += r; - return r; + return (b - (u_char *)buf); } int |