summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.bin/ldap/ber.c12
-rw-r--r--usr.sbin/ldapd/ber.c12
-rw-r--r--usr.sbin/snmpd/ber.c14
-rw-r--r--usr.sbin/ypldap/ber.c12
4 files changed, 17 insertions, 33 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
diff --git a/usr.sbin/ldapd/ber.c b/usr.sbin/ldapd/ber.c
index 94babe9693e..c2e15057870 100644
--- a/usr.sbin/ldapd/ber.c
+++ b/usr.sbin/ldapd/ber.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ber.c,v 1.18 2018/07/03 18:49:10 rob Exp $ */
+/* $OpenBSD: ber.c,v 1.19 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
diff --git a/usr.sbin/snmpd/ber.c b/usr.sbin/snmpd/ber.c
index b61edda95bd..454409facd6 100644
--- a/usr.sbin/snmpd/ber.c
+++ b/usr.sbin/snmpd/ber.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ber.c,v 1.37 2018/07/01 20:03:48 rob Exp $ */
+/* $OpenBSD: ber.c,v 1.38 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);
}
@@ -1271,7 +1271,7 @@ ber_free(struct ber *b)
static ssize_t
ber_getc(struct ber *b, u_char *c)
{
- return ber_read(b, c, 1);
+ return ber_readbuf(b, c, 1);
}
static ssize_t
@@ -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
diff --git a/usr.sbin/ypldap/ber.c b/usr.sbin/ypldap/ber.c
index 7d6b10e6565..4be86faba90 100644
--- a/usr.sbin/ypldap/ber.c
+++ b/usr.sbin/ypldap/ber.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ber.c,v 1.20 2018/07/03 18:49:10 rob Exp $ */
+/* $OpenBSD: ber.c,v 1.21 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