Commit Graph

47 Commits

Author SHA1 Message Date
ngie
a5e36bb16e bsnmp: explicitly test the return value for open_client_{local,udp} in snmp_open(..)
open_client_* returns -1 on failure; 0 on success. Ensure that the return value is
0 -- otherwise exit snmp_open(..).

MFC after:	1 week
Sponsored by:	Dell EMC Isilon
2017-03-20 17:26:13 +00:00
ngie
35ad315c79 bsnmp: don't leak snmp_client.fd in open_client_udp(..) on connect(2) failure
MFC after:	1 week
Sponsored by:	Dell EMC Isilon
2017-03-20 17:17:54 +00:00
ngie
7da6b42d42 snmp_table_fetch_async: don't leak work if snmp_pdu_send(..) fails
MFC after:	1 week
Reported by:	Coverity
CID:		1017276
2017-01-05 08:49:06 +00:00
ngie
ec5e0f180c Use calloc instead of malloc with buffers in snmp_{recv,send}_packet
This doesn't fix the issue noted in the PR, but at the very least it
cleans up the error so it looks a bit more sane, and in the event
that bsnmp did wander off into the weeds, the likelihood of it
crashing with more sensible output is greater, in my opinion

MFC counter set high so I have enough time to resolve the real
underlying bug in bsnmpwalk

MFC after:	1 month
PR:		215721
2017-01-04 07:53:01 +00:00
ngie
77cbb2793e Fix spelling errors; bump .Dd for the change
MFC after:	3 days
2017-01-01 05:23:01 +00:00
ngie
15dad82504 Bump .Dd for the spelling and .Nm updates
MFC after:	3 days
2017-01-01 05:16:24 +00:00
ngie
5ee4ee8c31 Fix spelling errors
MFC after:	3 days
Reported by:	igor
2017-01-01 05:14:58 +00:00
ngie
93373d9e9d bsnmpclient(3) also documents snmp_client_init, snmp_client_set_host,
and snmp_client_set_port. Add them to the NAME section

MFC after:	3 days
2017-01-01 05:13:54 +00:00
ngie
33903f83d5 snmp_discover_engine: fix up req/resp (PDU object) handling a bit
- Call snmp_pdu_free on req and resp when done with the objects
- Call snmp_pdu_free on req before calling snmp_pdu_create on it
  again

MFC after:	1 week
2016-12-31 23:20:57 +00:00
ngie
c628250e99 Unbreak the build by passing the string to strdup, not its length
MFC after:	1 week
X-MFC with:	r310931
Pointyhat to:	ngie
2016-12-31 11:24:12 +00:00
ngie
6069019fc0 Use strdup in snmp_parse_server(..) when possible instead of malloc+strcpy
This simplifies the code and mutes a Coverity warning about sc->cport being
improperly allocated

Reported by:	Coverity
CID:		1018247
MFC after:	1 week
2016-12-31 11:13:00 +00:00
ngie
4093156173 Prevent improper memory accesses after calling snmp_pdu_free and snmp_value_free
snmp_pdu_free: set pdu->nbindings to 0 to limit the damage that
could happen if a pdu was reused after calling the function, and
as both stack and heap allocation types are used in contrib/bsnmp
and usr.sbin/bsnmpd.

snmp_value_free: NULL out value->v.octetstring.octets after calling
free on it to prevent a double-free from occurring.

MFC after:      2 weeks
2016-12-29 00:20:03 +00:00
ngie
b2ff0ca59d style(9): snmp_send_packet(..): fix whitespace
MFC after:	3 days
2016-12-28 04:56:15 +00:00
ngie
65df443113 style(9): fix whitespace in pdu_encode_secparams(..)
MFC after:	3 days
2016-12-28 04:53:52 +00:00
ngie
6a228a1b19 style(9): clean up trailing whitespace
MFC after:	3 weeks
2016-12-27 23:32:54 +00:00
ngie
3a6e63dcae Be more strict about IpAddress type in snmp_value_parse(..)
- Use inet_pton with AF_INET instead of doing longhand with sscanf.
- Use gethostbyname2 with AF_INET to ensure that the hostname isn't
  accidentally parsed with another address family, e.g. AF_INET6.

NB: IpAddress per RFC-2578 is IPv4 only. Work is in progress to add
    the InetAddress type and friends documented in RFC-4001 and
    elsewhere (which supports IPv4, IPv6, and more).

MFC after:	2 weeks
2016-12-24 11:41:16 +00:00
ngie
f3cd3b6abc Minor style(9) fixes
- Trailing whitespace cleanup
- Sort variables in snmp_dialog(..) by alignment

No functional change

MFC after:	1 week
2016-12-24 11:30:24 +00:00
ngie
5d96cb434e Sort #includes
No functional change

MFC after:	3 days
2016-12-24 11:26:55 +00:00
ngie
1027db332b Clean up trailing and leading whitespace
Fix variable type alignment in snmp_dialog(..)

MFC after:	1 week
2016-12-18 05:31:54 +00:00
syrinx
b0a3ee5d95 Reply to a snmpEngineID discovery PDU with a Report PDU as per the
requirements of RFC 3414 section 4.

PR:	174974
Submitted by:	pguyot@kallisys.net
Reported by:	several people
Reviewed by:	bz@
2016-11-10 20:51:26 +00:00
syrinx
ea49fb0774 Fix a regression introduced in SVN r256678 that breaks USM header parsing
Reviewed by:	bz@
2016-10-24 21:05:23 +00:00
ngie
8e415d9c27 Fix the function signatures when MK_CRYPT == no for snmp_get_local_keys and
snmp_passwd_to_keys

MFC after: 1 week
Reported by: Beeblebrox <zaphod@berentweb.com>
2014-12-27 20:58:01 +00:00
harti
1d74874531 Fix a problem with OBJECT IDENTIFIER encoding: need to check the
second subid to be less than 40, not the first when the first
subid is 0 or 1.
2014-01-21 16:49:54 +00:00
delphij
7d5825ffd4 Fix bsnmpd remote denial of service vulnerability.
Reported by:	dinoex
Submitted by:	harti
Security:	FreeBSD-SA-14:01.bsnmpd
Security:	CVE-2014-1452
2014-01-14 18:58:57 +00:00
syrinx
8e524b7e82 Fix the -Wconversion warnings produced when compiling the SNMP agent. 2013-10-17 12:03:17 +00:00
syrinx
f7282ff245 Fix SNMP Error response PDUs and properly encode them when using v3 auth/encryption.
Reported by:	harti@
2013-10-17 11:49:46 +00:00
pfg
245e35ae97 Clean some 'svn:executable' properties in the tree.
Submitted by:	Christoph Mallon
MFC after:	3 days
2013-01-26 22:08:21 +00:00
joel
44b4398f7d Remove end of line whitespace. 2012-06-17 11:36:28 +00:00
joel
f7ba751662 Minor mdoc fixes. 2012-06-17 11:33:55 +00:00
syrinx
cdf73327e5 Bring in a SNMP module that allows configuration of SNMPv3 Notification targets.
Sponsored by:	The FreeBSD Foundation
Reviewed by:	philip
Approved by:	philip
2010-12-20 17:13:14 +00:00
syrinx
c913d3117c Silence the compiler warnings in libbsnmp by removing several (now)
unsed parameters.

Sponsored by:	The FreeBSD Foundation
Reviewed by:	philip@
2010-12-16 11:20:37 +00:00
syrinx
69401abe0a Add a forgotten file from r216294 and unbreak the build.
Sponsored by:	The FreeBSD Foundation
Reviewed by:	philip@ (mostly)
Approved by:	philip@
2010-12-08 15:52:06 +00:00
syrinx
ed79f703fb In bsnmpd(1) add support for SNMPv3 message processing model, including message authentication, packet encryption & view-based access control (RFC 3412, 3414, 3415).
Sponsored by:	The FreeBSD Foundation
Reviewed by:	philip@ (mostly)
Approved by:	philip@
2010-12-08 13:51:38 +00:00
uqs
7fc6083fed mdoc: drop even more redundant .Pp calls
No change in rendered output, less mandoc lint warnings.

Tool provided by:	Nobuyuki Koganemaru n-kogane at syd.odn.ne.jp
2010-10-19 12:35:40 +00:00
uqs
e5ed83efa9 mdoc: consistently spell our email addresses <foo@FreeBSD.org>
Reviewed by:	ru
Approved by:	harti
2010-05-24 06:26:38 +00:00
harti
247524ddce This commit was generated by cvs2svn to compensate for changes in r156066,
which included commits to RCS files with non-trunk default branches.
2006-02-27 16:16:18 +00:00
harti
9b4fc3d8f1 Virgin import of bsnmpd 1.12 2006-02-27 16:16:18 +00:00
harti
1973a24241 Vendor fix for the build problem of snmp_pf. Move the fallback definitions
for U?INT32_{MAX,MIN} from asn1.h into the .c files that actually require
them (the .h file doesn't refer to these macros).
2005-10-05 15:19:56 +00:00
harti
ebda350f0a This commit was generated by cvs2svn to compensate for changes in r150974,
which included commits to RCS files with non-trunk default branches.
2005-10-05 15:19:56 +00:00
harti
c45e21ccca These files are not needed and were imported by accident in the
previous import.
2005-10-04 14:51:55 +00:00
harti
efb2dfa177 Virgin import of bsnmpd 1.11 2005-10-04 14:41:06 +00:00
harti
a585c860e6 Virgin import of bsnmpd 1.10 2005-05-23 11:19:11 +00:00
harti
273b7adb85 Virgin import of bsnmpd 1.8 2005-02-28 17:27:11 +00:00
harti
d6d162437d Virgin import of bsnmpd 1.7 2004-08-06 13:38:30 +00:00
harti
2dce00c891 Import of bsnmpd 1.6 2004-04-14 16:20:14 +00:00
harti
37f8604ae2 Virgin import of bsnmpd 1.5a 2004-01-23 10:44:47 +00:00
harti
ea9d8683bc Virgin import of bsnmp 1.4 2003-11-10 08:53:38 +00:00