ngie [Wed, 8 Jun 2016 18:22:54 +0000 (18:22 +0000)]
MFC r300625:
Remove unnecessary memset(.., 0, ..)'s
The mem_alloc macro calls calloc (userspace) / malloc(.., M_WAITOK|M_ZERO)
under the covers, so zeroing out memory is already handled by the underlying
calls
ngie [Wed, 8 Jun 2016 17:49:03 +0000 (17:49 +0000)]
MFC r294507,r294567,r299466:
r294507 (by harti):
Fill the ifAlias leaf of the ifXTable with the interface description
if there is one available and it fits into the maximum size (64 characters).
r294567 (by bz):
Change the variable to a #define in order to make gcc happy which
otherwise will complain about "variably modified 'alias' at file scope".
Unbreaks the build on gcc platforms.
r299466 (by cem):
bsnmpd: Fix size of trapsink::comm to match other community arrays
This fixes a number of possible strcpy() buffer overruns between the various
community strings in trap.c.
ngie [Wed, 8 Jun 2016 17:43:04 +0000 (17:43 +0000)]
MFC r256678,r256680,r260986,r272878,r286402:
r256678 (by syrinx):
Fix SNMP Error response PDUs and properly encode them when using v3 auth/encryption.
r256680 (by syrinx):
Fix the -Wconversion warnings produced when compiling the SNMP agent.
r260986 (by harti):
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.
r272878 (by syrinx):
Fix a bug in decoding string indexes in snmp_target(3), thus causing
bsnmpd(1) to not send v3 notifications properly; while here add two
missing return statements which could lead to abort() in case of a
rollback
r286402 (by araujo):
Fix variable 'old' is used uninitialized whenever '&&' condition is false.
Spotted by clang.
ngie [Wed, 8 Jun 2016 17:34:37 +0000 (17:34 +0000)]
MFC r299701:
Move _bsnmptools_debug extern from bsnmpmap.c to bsnmptools.h
It was used in bsnmpmap.c but was stored in bsnmptools.c; moving the extern
to the header allows us to cover all of our bases for the variable, and allows
_bsnmptools_debug to be used in the future elsewhere -- not just bsnmpmap.c.
ngie [Wed, 8 Jun 2016 17:32:41 +0000 (17:32 +0000)]
MFC r299778:
Use a consistent errno save/restore pattern before running strtoul
- Save errno
- Set errno to 0
- Call strtoul
- Test errno (optional, but many calls to strtoul did this afterwards)
Some of the code was setting errno = 0 after calling strtoul, not setting
errno = 0, or setting errno to saved_errno after the call, but before the
test. These all have unwanted behavioral side-effects, depending on the
initial value of errno and whether or not the input to strtoul was correct
or incorrect.
ngie [Wed, 8 Jun 2016 17:30:29 +0000 (17:30 +0000)]
MFC r299766:
Fix logically dead code pointed out by clang/Coverity
parse_context, parse_user_security: test for validity of results from
parse_ascii(..) with by casting to int32_t and comparing to -1; comparing
unsigned types to negative values will always be false.
- getaddrinfo() sets res = NULL on failure and freeaddrinfo() always
dereferences its argument, so we should only free the address list after
a successful call.
- Address a second potential leak caused by getaddrinfo(AF_INET6)
overwriting the address list returned by getaddrinfo(AF_INET).
X-MFC-With: r300941
r300973:
Follow up to r300932
In the event MK_INET6 != no in userspace, but is disabled in the
kernel, or if there aren't any IPv6 addresses configured in userspace
(for lo0 and all physical interfaces), rpcbind would terminate
immediately instead of silently failing on
Skip over the IPv6 block to its respective cleanup with freeifaddrs if
creating the socket failed instead of terminating rpcbind immediately
ngie [Wed, 8 Jun 2016 14:07:43 +0000 (14:07 +0000)]
MFC r300939:
Use require.progs with bc instead of require.files with /usr/bin/bc
This will make things more flexible if the program path changes in the future,
and the test in and of itself doesn't call /usr/bin/bc -- it just calls bc
ngie [Wed, 8 Jun 2016 13:58:47 +0000 (13:58 +0000)]
MFC r300620,r300621:
r300620:
Use reallocf instead of malloc to fix leak with outbuf_pmap
The previous code overwrote outbuf_pmap's memory with malloc once per
loop iteration, which leaked its memory; use reallocf instead to ensure
that memory is properly free'd each loop iteration.
Add a outbuf_pmap = NULL in the failure case to avoid a double-free
at the bottom of the function.
ngie [Wed, 8 Jun 2016 13:49:59 +0000 (13:49 +0000)]
MFC r300430:
Wrap EXPAND(..) macro with a do-while(0) loop and put a single statement on each line
As a positive side-effect, this eliminates the double semicolons reported by Coverity:
the macro contained a trailing semicolon, in addition to the semicolon placed on
each line where EXPAND(..) was called.
ngie [Wed, 8 Jun 2016 13:40:07 +0000 (13:40 +0000)]
MFC r299844,r300931:
r299844:
Make hostid_save depend on hostid
r300931:
Make netif REQUIRE hostid
As noted in the PR, if etc/rc.d/zvol is removed, netif will be run before
hostid, and the MAC address generated for any bridge devices will be
non-deterministic. Make the MAC address generated be deterministic for
bridge devices by explicitly REQUIRE'ing hostid.
This fixes up the rest of the PR, inadvertently committed in r299844
truckman [Wed, 8 Jun 2016 01:17:22 +0000 (01:17 +0000)]
MFC r301139
The (i < PROMPTLEN - 1) test added by r300442 in the code for the default
case of \c in the prompt format string is a no-op. We already passed
this test at the top of the loop, and i has not yet been incremented in
this path. Change this test to (i < PROMPTLEN - 2).
truckman [Tue, 7 Jun 2016 16:56:15 +0000 (16:56 +0000)]
MFC r300564
Fix CID 1006692 in /usr/sbin/pw pw_log() function and other fixes
The length of the name returned from the $LOGNAME and $USER can be
very long and it was being concatenated to a fixed length buffer
with no bounds checking. Fix this problem by limiting the length
of the name copied.
Additionally, this name is actually used to create a format string
to be used in adding log file entries so embedded % characters in
the name could confuse *printf(), and embedded whitespace could
confuse a log file parser. Handle the former by escaping each %
with an additional %, and handle the latter by simply stripping it
out.
Clean up the code by moving the variable declarations to the top
of the function, formatting them to conform with style, and moving
intialization elsewhere.
Reduce code indentation by returning early in a couple of places.
ache [Sun, 5 Jun 2016 14:31:36 +0000 (14:31 +0000)]
MFC: r300956
1) Unifdef USE_WEAK_SEEDING since it is too obsolete to support and makes
reading hard.
2) Instead of doing range transformation in each and every function here,
do it single time directly in do_rand(). One "mod" operation overhead is not
a big deal, but the code looks nicer and possible future functions additions
or PRNG change do not miss range transformations neither have unneeded ones.
3) Use POSIX argument types for visible functions (cosmetic).
ache [Sun, 5 Jun 2016 14:04:54 +0000 (14:04 +0000)]
Prepare for merge of r300956. One year old r288030 which fix prototypes
can't be merged without conflicts and require merging of other versions
too and I don't want to go deep in that unmerged commits chain.
ache [Sun, 5 Jun 2016 13:39:31 +0000 (13:39 +0000)]
MFC: r300953
1) Unifdef USE_WEAK_SEEDING it is too obsolete to support and makes reading
harder.
2) ACM paper require seed to be in [1, 2^31-2] range, so use the same range
shifting as already done for rand(3). Also protect srandomdev() + TYPE_0 case
(non default) from negative seeds.
3) Don't check for valid "type" range in setstate(), it is always valid as
calculated. Instead add a check that rear pointer not exceeed end pointer.
MFC: r300965
Micro optimize: C standard guarantees that right shift for unsigned value
fills left bits with zero, and we have exact 32bit unsigned value
(uint32_t), so there is no reason to add "& 0x7fffffff" here.
The EFSYS_PREEMPT_DISABLE() and EFSYS_PREEMPT_ENABLE() macros
were used to ensure correct timing of I2C operations. The APIs
for I2C operations have been removed, so these macros have no
callers.
Submitted by: Andy Moreton <amoreton at solarflare.com>
Sponsored by: Solarflare Communications, Inc.
arybchik [Sat, 4 Jun 2016 16:57:38 +0000 (16:57 +0000)]
MFC r300011
sfxge(4): only raise an exception after MC assert or reboot in the common code
Fix efx_mcdi_request_poll so it only raises an exception if EIO is
reported from a detected MC assert or reboot. This prevents
an unnecessary exception being raised if an MCDI response error code
is trandlated to EIO.
Submitted by: Andy Moreton <amoreton at solarflare.com>
Sponsored by: Solarflare Communications, Inc.
arybchik [Sat, 4 Jun 2016 16:54:28 +0000 (16:54 +0000)]
MFC r300009
sfxge(4): fix Medford timer quantum calculation in common code
The event/timer block used sysclk in Huntington, but has been
moved to the dpcpu clock domain for Medford. Fix the computed
timer quantum to use the right clock.
Submitted by: Andy Moreton <amoreton at solarflare.com>
Sponsored by: Solarflare Communications, Inc.
arybchik [Sat, 4 Jun 2016 16:52:04 +0000 (16:52 +0000)]
MFC r300008
sfxge(4): query and use current MTU if setting the MTU fails
This allows the driver to fall back to the largest usable MTU if a
user attempts to configure an unprivileged function with an MTU higher
than that of the attached port.
Submitted by: Mark Spender <mspender at solarflare.com>
Sponsored by: Solarflare Communications, Inc.
arybchik [Sat, 4 Jun 2016 16:25:18 +0000 (16:25 +0000)]
MFC r299901
sfxge(4): cleanup: make VPD lookups quieter
A lookup on a VPD entry which is missing reports several failure
messages as it propagates through wrapper functions. Restructured
the wrappers to treat this gracefully as an expected case.
Submitted by: Richard Houldsworth <rhouldsworth at solarflare.com>
Sponsored by: Solarflare Communications, Inc.