OpenBSD CVS

CVS log for src/usr.sbin/snmpd/Attic/ber.c


[BACK] Up to [local] / src / usr.sbin / snmpd

Request diff between arbitrary revisions


Default branch: MAIN


Revision 1.52, Sat May 11 17:46:02 2019 UTC (5 years ago) by rob
Branch: MAIN
CVS Tags: HEAD
Changes since 1.51: +1 -1 lines
FILE REMOVED

The BER API is currently used by ldap, ldapd, ldapctl, ypldap, snmpd, and
snmpctl. Separate copies of ber.[ch] have existed and been maintained in sync
in ldap, ldapd, ypldap and snmpd.

This commit moves the BER API into /usr/lib/libutil. All current consumers
already link libutil. ldapd and snmpd regress passes, and release builds.

With help from tb@ and guenther@.

ok deraadt@, tb@

Revision 1.51 / (download) - annotate - [select for diffs], Sat Apr 27 14:58:15 2019 UTC (5 years, 1 month ago) by rob
Branch: MAIN
Changes since 1.50: +4 -3 lines
Diff to previous 1.50 (colored)

Only apply sign extension when less than eight bytes have been consumed. This
fixes a problem when handling large negative integers.

ok claudio@

Revision 1.50 / (download) - annotate - [select for diffs], Tue Nov 27 12:10:29 2018 UTC (5 years, 6 months ago) by martijn
Branch: MAIN
CVS Tags: OPENBSD_6_5_BASE, OPENBSD_6_5
Changes since 1.49: +23 -1 lines
Diff to previous 1.49 (colored)

Sync with ldap(1)

Revision 1.49 / (download) - annotate - [select for diffs], Tue Nov 20 07:20:21 2018 UTC (5 years, 6 months ago) by martijn
Branch: MAIN
Changes since 1.48: +3 -1 lines
Diff to previous 1.48 (colored)

Fix when ber_free_elements is called with a NULL-value.
Found via snmpctl snmp walk 127.0.0.1 oid 1

OK claudio@

Revision 1.48 / (download) - annotate - [select for diffs], Sun Aug 12 22:04:09 2018 UTC (5 years, 9 months ago) by rob
Branch: MAIN
CVS Tags: OPENBSD_6_4_BASE, OPENBSD_6_4
Changes since 1.47: +2 -2 lines
Diff to previous 1.47 (colored)

Change ber_write_elements() to return ssize_t instead of int.

ok claudio@

Revision 1.47 / (download) - annotate - [select for diffs], Fri Aug 3 01:51:28 2018 UTC (5 years, 10 months ago) by rob
Branch: MAIN
Changes since 1.46: +11 -2 lines
Diff to previous 1.46 (colored)

Place a limit on the number of elements in a ber sequence/set. This prevents
possible stack overflow due to recursion in ber_free_elements().

ok claudio@

Revision 1.46 / (download) - annotate - [select for diffs], Tue Jul 31 19:38:09 2018 UTC (5 years, 10 months ago) by rob
Branch: MAIN
Changes since 1.45: +63 -63 lines
Diff to previous 1.45 (colored)

Relocate some public functions above the internal functions comment.

ok claudio@

Revision 1.45 / (download) - annotate - [select for diffs], Tue Jul 31 11:37:18 2018 UTC (5 years, 10 months ago) by rob
Branch: MAIN
Changes since 1.44: +2 -2 lines
Diff to previous 1.44 (colored)

Fix some debugging output now that ber type and encoding are unsigned int.

ok claudio@

Revision 1.44 / (download) - annotate - [select for diffs], Tue Jul 31 11:01:29 2018 UTC (5 years, 10 months ago) by claudio
Branch: MAIN
Changes since 1.43: +16 -16 lines
Diff to previous 1.43 (colored)

Make ber type and encoding a unsigned int instead of unsigned long.
This way the size is the same on all archs and 32bit should be good enough.
OK rob@

Revision 1.43 / (download) - annotate - [select for diffs], Fri Jul 13 08:50:38 2018 UTC (5 years, 10 months ago) by rob
Branch: MAIN
Changes since 1.42: +5 -5 lines
Diff to previous 1.42 (colored)

Fix some comments referencing sockets which are not used by the ber api. The
api uses read and write buffers (byte streams) that are utilized by calling
applications which may or may not use sockets.

ok claudio@

buffer byte streams that applications then use for

Revision 1.42 / (download) - annotate - [select for diffs], Fri Jul 13 08:30:10 2018 UTC (5 years, 10 months ago) by rob
Branch: MAIN
Changes since 1.41: +5 -6 lines
Diff to previous 1.41 (colored)

Fix loop condition in ber.c. Discussed with claudio.

ok claudio@, jca@

Revision 1.41 / (download) - annotate - [select for diffs], Mon Jul 9 09:21:26 2018 UTC (5 years, 10 months ago) by jca
Branch: MAIN
Changes since 1.40: +16 -36 lines
Diff to previous 1.40 (colored)

Simplify ber_read()

After the removal of fd-based read/writes I could have trimmed the code
further.

- no socket-based reads so ber_read() doesn't need to loop until it gets
the desired amount of data
- return either the requested amount of data or -1/ECANCELED, the caller
shouldn't have to handle partial reads itself
- inline ber_readbuf() into ber_read()

ok rob@ claudio@ tb@

Revision 1.40 / (download) - annotate - [select for diffs], Wed Jul 4 15:21:24 2018 UTC (5 years, 10 months ago) by rob
Branch: MAIN
Changes since 1.39: +2 -4 lines
Diff to previous 1.39 (colored)

More whitespace.

Revision 1.39 / (download) - annotate - [select for diffs], Wed Jul 4 13:31:57 2018 UTC (5 years, 10 months ago) by rob
Branch: MAIN
Changes since 1.38: +2 -2 lines
Diff to previous 1.38 (colored)

Cleanup some whitespace.

Revision 1.38 / (download) - annotate - [select for diffs], Wed Jul 4 13:04:30 2018 UTC (5 years, 10 months ago) by rob
Branch: MAIN
Changes since 1.37: +5 -9 lines
Diff to previous 1.37 (colored)

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@

Revision 1.37 / (download) - annotate - [select for diffs], Sun Jul 1 20:03:48 2018 UTC (5 years, 11 months ago) by rob
Branch: MAIN
Changes since 1.36: +2 -2 lines
Diff to previous 1.36 (colored)

s/constructive/constructed in DPRINTF output.

Revision 1.36 / (download) - annotate - [select for diffs], Sat Jun 30 14:05:52 2018 UTC (5 years, 11 months ago) by sthen
Branch: MAIN
Changes since 1.35: +2 -2 lines
Diff to previous 1.35 (colored)

revert ber.c r1.34, this break SNMPv3 authentication

Revision 1.35 / (download) - annotate - [select for diffs], Fri Jun 29 19:28:02 2018 UTC (5 years, 11 months ago) by rob
Branch: MAIN
Changes since 1.34: +14 -1 lines
Diff to previous 1.34 (colored)

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.

Revision 1.34 / (download) - annotate - [select for diffs], Fri Jun 29 15:18:03 2018 UTC (5 years, 11 months ago) by rob
Branch: MAIN
Changes since 1.33: +2 -2 lines
Diff to previous 1.33 (colored)

Synchronize ber.c and ber.h across ldap, ldapd, and ypldap, and reduce diff
with snmpd. More tweaks to come once things are fully synchronized.

Feedback from claudio and Robert Klein.

Ok claudio@

Revision 1.33 / (download) - annotate - [select for diffs], Wed Jun 27 13:22:17 2018 UTC (5 years, 11 months ago) by rob
Branch: MAIN
Changes since 1.32: +2 -2 lines
Diff to previous 1.32 (colored)

Synchronize correct processing of BER_TYPE_EOC. Fixes support for empty LDAP
passwords. A similar fix was applied to snmpd in 2010 (rev 1.23).

Pointers from Reyk.

Ok claudio@

Revision 1.32 / (download) - annotate - [select for diffs], Thu Feb 8 18:02:06 2018 UTC (6 years, 3 months ago) by jca
Branch: MAIN
CVS Tags: OPENBSD_6_3_BASE, OPENBSD_6_3
Changes since 1.31: +6 -22 lines
Diff to previous 1.31 (colored)

Kill ber.c support for direct fd read/writes

This mechanism is already unused and annotated with lots of XXX's, no
need to keep it around.  ok claudio@

Revision 1.31 / (download) - annotate - [select for diffs], Sat Mar 5 03:31:36 2016 UTC (8 years, 2 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_6_2_BASE, OPENBSD_6_2, OPENBSD_6_1_BASE, OPENBSD_6_1, OPENBSD_6_0_BASE, OPENBSD_6_0
Changes since 1.30: +4 -4 lines
Diff to previous 1.30 (colored)

mirror memset changes to ber.c made in ldapd (these 3 daemons
have subtly modified copies of the file)
from rob pierce

Revision 1.30 / (download) - annotate - [select for diffs], Sat Dec 5 06:42:18 2015 UTC (8 years, 5 months ago) by mmcc
Branch: MAIN
CVS Tags: OPENBSD_5_9_BASE, OPENBSD_5_9
Changes since 1.29: +3 -4 lines
Diff to previous 1.29 (colored)

strings.h -> string.h to prevent an implicit declaration warning. Also
remove a handful of NULL-checks before free().

Revision 1.29 / (download) - annotate - [select for diffs], Thu Feb 12 00:30:38 2015 UTC (9 years, 3 months ago) by pelikan
Branch: MAIN
CVS Tags: OPENBSD_5_8_BASE, OPENBSD_5_8, OPENBSD_5_7_BASE, OPENBSD_5_7
Changes since 1.28: +31 -14 lines
Diff to previous 1.28 (colored)

ber_printf_elements should return NULL if any of its parts fail.

Leave the error handling up to its callers.

ok reyk

Revision 1.28 / (download) - annotate - [select for diffs], Fri Jan 16 00:05:13 2015 UTC (9 years, 4 months ago) by deraadt
Branch: MAIN
Changes since 1.27: +3 -3 lines
Diff to previous 1.27 (colored)

first batch of cleanup to programs based upon the namespace cleanups
in net/pfvar.h sys/proc.h sys/ucred.h arpa/nameser.h
change to PATH_MAX, reduce use of MIN() and MAX(), HOST_NAME_MAX+1,
LOGIN_NAME_MAX, etc etc
ok millert guenther, some review by doug

Revision 1.27 / (download) - annotate - [select for diffs], Fri Apr 25 06:57:11 2014 UTC (10 years, 1 month ago) by blambert
Branch: MAIN
CVS Tags: OPENBSD_5_6_BASE, OPENBSD_5_6
Changes since 1.26: +9 -3 lines
Diff to previous 1.26 (colored)

Support running user-defined actions on receipt of snmp traps.

testing sthen@
much man page guidance jmc@
ok reyk@

Revision 1.26 / (download) - annotate - [select for diffs], Mon Apr 14 12:55:10 2014 UTC (10 years, 1 month ago) by blambert
Branch: MAIN
Changes since 1.25: +2 -1 lines
Diff to previous 1.25 (colored)

Make snmpd use the AgentX protcol for accepting trap requests.
AgentX notifications are the only portion implemented right now;
get in the tree to flesh out the remainder.

ok reyk@ benno@

Revision 1.25 / (download) - annotate - [select for diffs], Tue Oct 1 12:41:47 2013 UTC (10 years, 8 months ago) by reyk
Branch: MAIN
CVS Tags: OPENBSD_5_5_BASE, OPENBSD_5_5
Changes since 1.24: +27 -1 lines
Diff to previous 1.24 (colored)

Add initial SNMP client utility to snmpctl(8).
For example, snmpctl snmp walk 127.0.0.1

commit it deraadt@

Revision 1.24 / (download) - annotate - [select for diffs], Mon Sep 17 16:30:34 2012 UTC (11 years, 8 months ago) by reyk
Branch: MAIN
CVS Tags: OPENBSD_5_4_BASE, OPENBSD_5_4, OPENBSD_5_3_BASE, OPENBSD_5_3
Changes since 1.23: +45 -22 lines
Diff to previous 1.23 (colored)

Add initial SNMPv3 support to snmpd(8).

Traps are still sent via SNMPv2 protocol. They can neither be
authenticated nor encrypted. - Transport mode is still UDP. Not
additional transport subsystems were added. - Only the User-based
Security Model (USM, RFC3414) is supported.  View-Based Access Control
(VACM, RFC3415) is not included. - Configuration is described in
snmpd.conf(5).

This diff includes a few minor changes to ber.c/h adding a necessary
callback for the USM HMAC calculation and merging it with other
minor changes from ldapd's ber code.

From Gerhard Roth at genua
ok claudio@ reyk@

Revision 1.23 / (download) - annotate - [select for diffs], Mon Sep 20 08:30:13 2010 UTC (13 years, 8 months ago) by martinh
Branch: MAIN
CVS Tags: OPENBSD_5_2_BASE, OPENBSD_5_2, OPENBSD_5_1_BASE, OPENBSD_5_1, OPENBSD_5_0_BASE, OPENBSD_5_0, OPENBSD_4_9_BASE, OPENBSD_4_9
Changes since 1.22: +3 -2 lines
Diff to previous 1.22 (colored)

Allow output of null values with a context class. This is used in SNMPv2 to
return an error exception value for a varbind result ("noSuchObject[0]
IMPLICIT NULL" in rfc1905).

Revision 1.22 / (download) - annotate - [select for diffs], Mon Jun 14 13:46:08 2010 UTC (13 years, 11 months ago) by martinh
Branch: MAIN
CVS Tags: OPENBSD_4_8_BASE, OPENBSD_4_8
Changes since 1.21: +6 -6 lines
Diff to previous 1.21 (colored)

Fixes unlinking the first element inside a set or a sequence, and
fix reading empty sequences/sets. This minimizes the changes against
ldapd.

"looks good" pyr@, ok reyk@

Revision 1.21 / (download) - annotate - [select for diffs], Tue Jun 8 17:52:47 2010 UTC (13 years, 11 months ago) by martinh
Branch: MAIN
Changes since 1.20: +5 -5 lines
Diff to previous 1.20 (colored)

ber_calc_len() is not an internal function, so adjust the comment.

from Dawe

Revision 1.20 / (download) - annotate - [select for diffs], Wed Feb 24 14:09:45 2010 UTC (14 years, 3 months ago) by jmc
Branch: MAIN
CVS Tags: OPENBSD_4_7_BASE, OPENBSD_4_7
Changes since 1.19: +2 -5 lines
Diff to previous 1.19 (colored)

match code and doc; ok claudio

Revision 1.19 / (download) - annotate - [select for diffs], Wed Dec 16 22:17:53 2009 UTC (14 years, 5 months ago) by deraadt
Branch: MAIN
Changes since 1.18: +2 -5 lines
Diff to previous 1.18 (colored)

knf and unused variables

Revision 1.18 / (download) - annotate - [select for diffs], Thu Nov 12 15:28:32 2009 UTC (14 years, 6 months ago) by deraadt
Branch: MAIN
Changes since 1.17: +2 -2 lines
Diff to previous 1.17 (colored)

accessses 1 entry too far, found by parfait, ok jsg claudio

Revision 1.17 / (download) - annotate - [select for diffs], Thu Jun 4 18:03:07 2009 UTC (15 years ago) by jsg
Branch: MAIN
CVS Tags: OPENBSD_4_6_BASE, OPENBSD_4_6
Changes since 1.16: +2 -2 lines
Diff to previous 1.16 (colored)

Make the types of ber_read() decl match the prototype.
'looks good' pyr@

Revision 1.16 / (download) - annotate - [select for diffs], Sat Jan 3 18:41:41 2009 UTC (15 years, 5 months ago) by aschrijver
Branch: MAIN
CVS Tags: OPENBSD_4_5_BASE, OPENBSD_4_5
Changes since 1.15: +54 -1 lines
Diff to previous 1.15 (colored)



Sync with ypldap.  Add ber_{add,get}_enumerated.

OK reyk@

Revision 1.15 / (download) - annotate - [select for diffs], Sun Jun 29 16:00:22 2008 UTC (15 years, 11 months ago) by ragge
Branch: MAIN
CVS Tags: OPENBSD_4_4_BASE, OPENBSD_4_4
Changes since 1.14: +3 -3 lines
Diff to previous 1.14 (colored)

Use C99, not gcc-specific variadics.  Ok miod@.

Revision 1.14 / (download) - annotate - [select for diffs], Tue Mar 18 16:57:58 2008 UTC (16 years, 2 months ago) by reyk
Branch: MAIN
Changes since 1.13: +19 -37 lines
Diff to previous 1.13 (colored)

remove ber_add_astring and make it the default behaviour in
ber_add_string, ber_add_nstring, and ber_add_bitstring to allocate and
copy the provided buffer instead of just attaching it to the ber
element.  this may add some overhead but fixes and avoids some bugs
with static buffers and simplifies the ber api again.

From Matthew at Dempsky dot org
With input from claudio@

Revision 1.13 / (download) - annotate - [select for diffs], Tue Mar 18 14:53:07 2008 UTC (16 years, 2 months ago) by reyk
Branch: MAIN
Changes since 1.12: +2 -2 lines
Diff to previous 1.12 (colored)

fix bug that ber_oid2ber skips the first byte when encoding powers of
128.  E.g., it will encode 128 as 0x00 instead of 0x81 0x00.

From Matthew at Dempsky dot org

Revision 1.12 / (download) - annotate - [select for diffs], Fri Mar 14 15:22:22 2008 UTC (16 years, 2 months ago) by reyk
Branch: MAIN
Changes since 1.11: +23 -1 lines
Diff to previous 1.11 (colored)

add a new ber function ber_add_astring() that strdups the string and
sets the be_free flag (which is required in some cases).  this will
make it easier because it is done manually at some places in the code.

discussed with dlg

Revision 1.11 / (download) - annotate - [select for diffs], Wed Mar 12 17:48:27 2008 UTC (16 years, 2 months ago) by reyk
Branch: MAIN
Changes since 1.10: +1 -3 lines
Diff to previous 1.10 (colored)

remove noisy warning message

ok claudio@

Revision 1.10 / (download) - annotate - [select for diffs], Wed Mar 12 17:41:38 2008 UTC (16 years, 2 months ago) by reyk
Branch: MAIN
Changes since 1.9: +9 -3 lines
Diff to previous 1.9 (colored)

fix a memleak in the ber_read_elements() error case.

ok claudio@

Revision 1.9 / (download) - annotate - [select for diffs], Wed Mar 12 14:30:11 2008 UTC (16 years, 2 months ago) by claudio
Branch: MAIN
Changes since 1.8: +4 -1 lines
Diff to previous 1.8 (colored)

Check that the current ber element is a sequence or a set when '{' or '('
is used.
OK reyk@

Revision 1.8 / (download) - annotate - [select for diffs], Wed Mar 12 13:09:12 2008 UTC (16 years, 2 months ago) by claudio
Branch: MAIN
Changes since 1.7: +7 -5 lines
Diff to previous 1.7 (colored)

SNMP has a restricted BER encoding especially all encodings use the
definite-length from. So bail out with an error if this is not the case.
OK cloder@, reyk@
cvs: ----------------------------------------------------------------------

Revision 1.7 / (download) - annotate - [select for diffs], Wed Mar 12 13:06:09 2008 UTC (16 years, 2 months ago) by claudio
Branch: MAIN
Changes since 1.6: +5 -1 lines
Diff to previous 1.6 (colored)

Return an error if more data is requested even though the buffer is empty.
Fixes an infinite loop seen by cloder@. OK cloder@, reyk@

Revision 1.6 / (download) - annotate - [select for diffs], Sat Feb 9 13:03:01 2008 UTC (16 years, 3 months ago) by reyk
Branch: MAIN
CVS Tags: OPENBSD_4_3_BASE, OPENBSD_4_3
Changes since 1.5: +8 -1 lines
Diff to previous 1.5 (colored)

fix a memleak in the snmp engine and the ber i/o; free the dynamically
allocated ber write buffer after using it.  extend the ber api with a
ber_free() function to do the required cleanup.

Thanks to Will Backman (bitgeist at yahoo dot com) for testing and for
figuring out that there was a memleak.

Revision 1.5 / (download) - annotate - [select for diffs], Thu Jan 3 14:44:08 2008 UTC (16 years, 5 months ago) by reyk
Branch: MAIN
Changes since 1.4: +14 -1 lines
Diff to previous 1.4 (colored)

scalars have an index of 0 in the returned oid (like sysDescr.0).

Revision 1.4 / (download) - annotate - [select for diffs], Fri Dec 7 10:08:40 2007 UTC (16 years, 5 months ago) by reyk
Branch: MAIN
Changes since 1.3: +2 -2 lines
Diff to previous 1.3 (colored)

comparison betweem signed and unsigned

Revision 1.3 / (download) - annotate - [select for diffs], Fri Dec 7 09:50:51 2007 UTC (16 years, 5 months ago) by reyk
Branch: MAIN
Changes since 1.2: +5 -1 lines
Diff to previous 1.2 (colored)

add a new 'd' format to ber_printf_elements to pass ints instead of
long longs; you have to pass the right type with vargs. this finally
fixes the previous problem on i386.

discussed with claudio

Revision 1.2 / (download) - annotate - [select for diffs], Wed Dec 5 23:29:19 2007 UTC (16 years, 6 months ago) by reyk
Branch: MAIN
Changes since 1.1: +5 -5 lines
Diff to previous 1.1 (colored)

more typos in comments etc.

From Leonardo Chiquitto (leonardo at ngdn dot org)

Revision 1.1 / (download) - annotate - [select for diffs], Wed Dec 5 09:22:44 2007 UTC (16 years, 6 months ago) by reyk
Branch: MAIN

Start working on snmpd(8) and snmpctl(8), a lightweight SNMP implementation
for OpenBSD.  SNMP is a necessary evil.  This is work in progress, don't
expect too much from it yet.

ok deraadt@

This form allows you to request diff's between any two revisions of a file. You may select a symbolic revision name using the selection box or you may type in a numeric name using the type-in text box.