[Bug 236930] bsnmpd snmp_target wrong port

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Mon Apr 1 10:49:18 UTC 2019


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236930

            Bug ID: 236930
           Summary: bsnmpd snmp_target wrong port
           Product: Base System
           Version: 11.2-STABLE
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: bin
          Assignee: bugs at FreeBSD.org
          Reporter: t.ermakova at securitycode.ru

Created attachment 203290
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=203290&action=edit
A fix-patch

We've been trying to use smnp traps via snmp_target module and have encountered
the situation, when big port number is not set correctly.
I've managed to track this down in trap.c. Here is a simple example in c++,
showing the problem. 

vector<uint8_t> address = {0x07, 0x06, 0x05, 0x04, 0x1a, 0x85};
unsigned short from_code = htons(address[4]) << 8 | htons(address[5]) << 0;
unsigned short correct = htons(address[4] << 8 | address[5]);
cout << ntohs(from_code) << ' ' << ntohs(correct) << endl;

The output is:
133 6789

133 is 0x85, while 6789 is the expected result for {0x1a, 0x85}.

I'm also attaching the patch that we'll be using in our project, so a
reply/review would be great. Thanks in advance.

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the freebsd-bugs mailing list