summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorclaudio <claudio@openbsd.org>2008-03-12 13:06:09 +0000
committerclaudio <claudio@openbsd.org>2008-03-12 13:06:09 +0000
commit35e3a642bccb81108cf7d6a9bdbfbcab10a4bf32 (patch)
tree04fde07d1818102d5b791a10e8a19f16b584320e
parentFix comment typo, of -> if. (diff)
downloadwireguard-openbsd-35e3a642bccb81108cf7d6a9bdbfbcab10a4bf32.tar.xz
wireguard-openbsd-35e3a642bccb81108cf7d6a9bdbfbcab10a4bf32.zip
Return an error if more data is requested even though the buffer is empty.
Fixes an infinite loop seen by cloder@. OK cloder@, reyk@
-rw-r--r--usr.sbin/snmpd/ber.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/usr.sbin/snmpd/ber.c b/usr.sbin/snmpd/ber.c
index e146acd47d1..0b96000f936 100644
--- a/usr.sbin/snmpd/ber.c
+++ b/usr.sbin/snmpd/ber.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ber.c,v 1.6 2008/02/09 13:03:01 reyk Exp $ */
+/* $OpenBSD: ber.c,v 1.7 2008/03/12 13:06:09 claudio Exp $ */
/*
* Copyright (c) 2007 Reyk Floeter <reyk@vantronix.net>
@@ -1102,6 +1102,10 @@ ber_readbuf(struct ber *b, void *buf, size_t nbytes)
sz = b->br_rend - b->br_rptr;
len = MIN(nbytes, sz);
+ if (len == 0) {
+ errno = ECANCELED;
+ return (-1); /* end of buffer and parser wants more data */
+ }
bcopy(b->br_rptr, buf, len);
b->br_rptr += len;