Page MenuHomeFreeBSD

libbsnmp: make snmp_parse_server() more robust when lacking info
Needs ReviewPublic

Authored by glebius on Thu, Jun 26, 7:57 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Jul 11, 11:41 PM
Unknown Object (File)
Fri, Jul 11, 8:03 AM
Unknown Object (File)
Tue, Jul 8, 4:36 PM
Unknown Object (File)
Mon, Jul 7, 12:14 PM
Unknown Object (File)
Sun, Jul 6, 5:34 PM
Unknown Object (File)
Sat, Jul 5, 6:33 PM
Unknown Object (File)
Wed, Jul 2, 3:16 PM
Unknown Object (File)
Sun, Jun 29, 4:01 AM
Subscribers

Details

Reviewers
harti
syrinx
Summary

Per documentation snmp_parse_server() has all 4 components optional. We
want inputs like "udp::", "udp6::", "stream::" work with local default
sockets and even degenerate case of "" shall end with defaults instead of
a failure.

While here make the parser more robust. Make all parser helpers to behave
the same way: on successful return they are responsible to update both
start & end of matched substring and return next characater to parse.
This eliminates special handling of IPv6 and port parser that used to need
to skip a character, and thus eliminates unchecked step forward in
snmp_parse_server() itself. Additionally:

  • use strchr(3) instead of own cycle
  • INET_ADDRSTRLEN includes space for NUL character
  • INET6_ADDRSTRLEN includes both the scope and NUL character
  • prefer sizeof() comparison instead of preprocessor define repetitive use

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 65110
Build 61993: arc lint + arc unit