summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorrob <rob@cvs.openbsd.org>2018-06-29 19:28:03 +0000
committerrob <rob@cvs.openbsd.org>2018-06-29 19:28:03 +0000
commita3cb339e98f7e371b2cacea84c547d932dee230a (patch)
tree758514e5747638e335c79445d024aac024ef6c27 /usr.sbin
parent24d6fbda4327c2028c5010f38bc7b7a8871849cb (diff)
Add ber_free_element() to snmpd instance, reducing the diff with ldap, ldapd,
and ypldap. This function is not called by snmpd. This is the penultimate commit prior to full sync between these four consumers of ber.
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/snmpd/ber.36
-rw-r--r--usr.sbin/snmpd/ber.c15
-rw-r--r--usr.sbin/snmpd/ber.h3
3 files changed, 21 insertions, 3 deletions
diff --git a/usr.sbin/snmpd/ber.3 b/usr.sbin/snmpd/ber.3
index 96ed5093c58..47b36141c9f 100644
--- a/usr.sbin/snmpd/ber.3
+++ b/usr.sbin/snmpd/ber.3
@@ -1,4 +1,4 @@
-.\" $OpenBSD: ber.3,v 1.14 2018/06/29 15:18:03 rob Exp $
+.\" $OpenBSD: ber.3,v 1.15 2018/06/29 19:28:02 rob Exp $
.\"
.\" Copyright (c) 2007, 2012 Reyk Floeter <reyk@openbsd.org>
.\"
@@ -55,6 +55,7 @@
.Nm ber_set_readbuf ,
.Nm ber_read_elements ,
.Nm ber_getpos ,
+.Nm ber_free_element ,
.Nm ber_free_elements ,
.Nm ber_calc_len ,
.Nm ber_set_application ,
@@ -138,6 +139,8 @@
.Ft off_t
.Fn "ber_getpos" "struct ber_element *elm"
.Ft "void"
+.Fn "ber_free_element" "struct ber_element *root"
+.Ft "void"
.Fn "ber_free_elements" "struct ber_element *root"
.Ft "size_t"
.Fn "ber_calc_len" "struct ber_element *root"
@@ -211,6 +214,7 @@ struct ber_oid {
.Fn ber_set_readbuf ,
.Fn ber_read_elements ,
.Fn ber_getpos ,
+.Fn ber_free_element ,
.Fn ber_free_elements ,
.Fn ber_set_application ,
.Fn ber_set_writecallback ,
diff --git a/usr.sbin/snmpd/ber.c b/usr.sbin/snmpd/ber.c
index 1255910f6c7..72a9cf70640 100644
--- a/usr.sbin/snmpd/ber.c
+++ b/usr.sbin/snmpd/ber.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ber.c,v 1.34 2018/06/29 15:18:03 rob Exp $ */
+/* $OpenBSD: ber.c,v 1.35 2018/06/29 19:28:02 rob Exp $ */
/*
* Copyright (c) 2007, 2012 Reyk Floeter <reyk@openbsd.org>
@@ -841,6 +841,19 @@ ber_getpos(struct ber_element *elm)
}
void
+ber_free_element(struct ber_element *root)
+{
+ if (root->be_sub && (root->be_encoding == BER_TYPE_SEQUENCE ||
+ root->be_encoding == BER_TYPE_SET))
+ ber_free_elements(root->be_sub);
+ if (root->be_free && (root->be_encoding == BER_TYPE_OCTETSTRING ||
+ root->be_encoding == BER_TYPE_BITSTRING ||
+ root->be_encoding == BER_TYPE_OBJECT))
+ free(root->be_val);
+ free(root);
+}
+
+void
ber_free_elements(struct ber_element *root)
{
if (root->be_sub && (root->be_encoding == BER_TYPE_SEQUENCE ||
diff --git a/usr.sbin/snmpd/ber.h b/usr.sbin/snmpd/ber.h
index 7fc4a67915a..4a8f194f4a7 100644
--- a/usr.sbin/snmpd/ber.h
+++ b/usr.sbin/snmpd/ber.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ber.h,v 1.10 2018/02/08 18:02:06 jca Exp $ */
+/* $OpenBSD: ber.h,v 1.11 2018/06/29 19:28:02 rob Exp $ */
/*
* Copyright (c) 2007, 2012 Reyk Floeter <reyk@openbsd.org>
@@ -127,6 +127,7 @@ int ber_write_elements(struct ber *, struct ber_element *);
void ber_set_readbuf(struct ber *, void *, size_t);
struct ber_element *ber_read_elements(struct ber *, struct ber_element *);
off_t ber_getpos(struct ber_element *);
+void ber_free_element(struct ber_element *);
void ber_free_elements(struct ber_element *);
size_t ber_calc_len(struct ber_element *);
void ber_set_application(struct ber *,