1
0
mirror of https://github.com/openbsd/src.git synced 2025-01-10 06:47:55 -08:00
Commit Graph

24 Commits

Author SHA1 Message Date
martijn
469af3a4b6 When decoding a sequence/set, make sure that:
- We don't create an uninitialized element when there are no subelements to
  decode
- If subelements overflow we return EINVAL

While here fix an eyesore of a line continuation.

OK claudio@
2022-11-03 17:58:10 +00:00
martijn
893ac8ce76 Sync ober_oid_cmp with ax_oid_cmp from libagentx.
This flips the returned signedness and adds the weight of 2 for
parent-child relationship in both direction.

This makes ober_oid_cmp consistent with the rest of the *_cmp based
functions.

OK tb@
2021-10-21 08:17:33 +00:00
martijn
63beb5678c Add ober_dup. Needed for upcoming SNMPv3 support for trap receiver in
snmpd(8).

OK jmatthew@
OK deraadt@ for bumping libutil now.
2021-08-29 13:27:11 +00:00
martijn
561e001134 Make the ober_get_* set of function to accept a NULL-pointer.
This allows us to do ber-type checking inside ober_scanf_elements, which
will allow for stricter ASN.1 parsing in the future.

Manpage feedback and OK claudio@, jmc@
OK claudio@
2021-02-22 17:15:02 +00:00
martijn
b8d19846be Add '$' to ober_scanf_elements().
This allows us to enforce end of sequence/set without having to manually
check be_next for NULL.

No lib bump needed according to millert@
OK millert@ rob@
2021-01-28 19:56:33 +00:00
rob
f273e38053 Gracefully handle any erroneous closing bracket/brace trailers in
ober_scanf_elements().

OK martijn@
2021-01-22 18:27:52 +00:00
rob
68ec4783ef Valid integer and enumerated types always have non-zero length. Perform
check to ensure we avoid a possible (undefined) negative shift. Found
with clang static analyzer.

Tweaked and OK martijn@
2021-01-22 03:20:56 +00:00
martijn
00f4a9fb7d Missed one case of errno not being set in previous.
double check and OK tb@
2020-09-03 19:09:57 +00:00
martijn
1f7940eec8 Make sure ober_read_elements sets errno on every case where NULL is
returned.

OK deraadt@ tb@
2020-09-03 17:01:15 +00:00
tb
696b58997f The ber_* namespace is used by liblber since time immemorial,
so move our BER API to the unused ober_* prefix to avoid some
breakage in ports.

Problem diagnosed by jmatthew with ber_free() in samba, but
there are many others as pointed out by sthen.

tests & ok rob
ok sthen (who had an almost identical diff for libutil)
"go head hit it" deraadt
2019-10-24 12:39:26 +00:00
martijn
2b859d28e7 Revert previous. There were some users of the quirky behaviour that were
missed during code scan.
2019-08-15 06:11:18 +00:00
martijn
2e9eee5b0a Make ber_scanf_elements's 'e' attribute eat the element.
Right now all consumers use 'e' at the end of the list, so no regressions
should be introduced.

OK claudio@
Seems sensible to deraadt@
2019-08-14 17:20:41 +00:00
martijn
497d37e3d0 Make sure that ber in ber_scanf_elements is not NULL before parsing format
where ber is utilized. This also allows us to remove the ber->be_next
check, which can cause weird behaviour, because a NULL be_next would result
in parsing the last element twice.

OK claudio@ on previous version
OK rob@
2019-08-14 04:48:13 +00:00
martijn
f6a2c1a0c0 Don't use a 0 element to determine the end of an OID when comparing two
OIDS. This can result in false equality matches.

OK claudio@
2019-08-05 12:38:14 +00:00
martijn
a93a062f22 There's no reason why the first digit of an OID can't be 0.
OK claudio@
"Good find" deraadt@
2019-08-05 12:30:50 +00:00
rob
260378df22 Limit maximum number of length octets to platform independent sizeof(int32_t).
Problem noticed by bluhm@. Discussed on hackers.

ok claudio@
2019-06-01 19:40:05 +00:00
rob
285652d4c9 whitespace 2019-05-21 13:29:44 +00:00
rob
ff8cfb38b9 Add XXX to a comment. 2019-05-16 21:12:33 +00:00
rob
d1325eace2 Enable support for the writting of BITSTRING by treating it as an OCTETSTRING.
ok claudio@
2019-05-12 20:25:10 +00:00
rob
b0a6858b39 Enforce smallest number of contents octets for int (and enum).
ok claudio@
2019-05-12 20:13:08 +00:00
rob
e26852eb43 Fail early if a (universal) primitive type identifies as constructed, or if a
boolean has a contents length other than 1.

ok claudio@
2019-05-12 18:11:51 +00:00
rob
9248c21961 Enforce minimal number of octets for tag > 30.
"sure" claudio@
2019-05-12 17:50:32 +00:00
rob
4880bb4062 In long form encoding, explicitly prohibit an initial length octet of 0xff
which is reserved for future use.

ok claudio@
2019-05-12 17:42:14 +00:00
rob
d4b95dc451 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@
2019-05-11 17:46:02 +00:00