freebsd-skq/usr.sbin
Don Lewis 95320acebc Fix multiple Coverity Out-of-bounds access false postive issues in CAM
The currently used idiom for clearing the part of a ccb after its
header generates one or two Coverity errors for each time it is
used.  All instances generate an Out-of-bounds access (ARRAY_VS_SINGLETON)
error because of the treatment of the header as a two element array,
with a pointer to the non-existent second element being passed as
the starting address to bzero().  Some instances also alsp generate
Out-of-bounds access (OVERRUN) errors, probably because the space
being cleared is larger than the sizeofstruct ccb_hdr).

In addition, this idiom is difficult for humans to understand and
it is error prone.  The user has to chose the proper struct ccb_*
type (which does not appear in the surrounding code) for the sizeof()
in the length calculation.  I found several instances where the
length was incorrect, which could cause either an actual out of
bounds write, or incompletely clear the ccb.

A better way is to write the code to clear the ccb itself starting
at sizeof(ccb_hdr) bytes from the start of the ccb, and calculate
the length based on the specific type of struct ccb_* being cleared
as specified by the union ccb member being used.  The latter can
normally be seen in the nearby code.  This is friendlier for Coverity
and other static analysis tools because they will see that the
intent is to clear the trailing part of the ccb.

Wrap all of the boilerplate code in a convenient macro that only
requires a pointer to the desired union ccb member (or a pointer
to the union ccb itself) as an argument.

Reported by:	Coverity
CID:		1007578, 1008684, 1009724, 1009773, 1011304, 1011306
CID:		1011307, 1011308, 1011309, 1011310, 1011311, 1011312
CID:		1011313, 1011314, 1011315, 1011316, 1011317, 1011318
CID:		1011319, 1011320, 1011321, 1011322, 1011324, 1011325
CID:		1011326, 1011327, 1011328, 1011329, 1011330, 1011374
CID:		1011390, 1011391, 1011392, 1011393, 1011394, 1011395
CID:		1011396, 1011397, 1011398, 1011399, 1011400, 1011401
CID:		1011402, 1011403, 1011404, 1011405, 1011406, 1011408
CID:		1011409, 1011410, 1011411, 1011412, 1011413, 1011414
CID:		1017461, 1018387, 1086860, 1086874, 1194257, 1229897
CID:		1229968, 1306229, 1306234, 1331282, 1331283, 1331294
CID:		1331295, 1331535, 1331536, 1331539, 1331540, 1341623
CID:		1341624, 1341637, 1341638, 1355264, 1355324
Reviewed by:	scottl, ken, delphij, imp
MFH:		1 month
Differential Revision:	https://reviews.freebsd.org/D6496
2016-05-24 00:57:11 +00:00
..
ac
accton Create an acct package for accounting tools. 2016-01-21 17:49:10 +00:00
acpi Merge ACPICA 20160422. 2016-04-27 19:09:21 +00:00
adduser
amd MFH 2016-03-02 16:14:46 +00:00
ancontrol
apm Create a package for apm(8). 2016-01-21 18:41:55 +00:00
apmd MFH 2016-03-02 16:14:46 +00:00
arp rtsock requests for deleting interface address lles started to return EPERM 2015-09-27 04:54:29 +00:00
asf Update dependencies after r291406 added libelf to libkvm. 2015-12-01 05:18:48 +00:00
audit
auditd
auditdistd DIRDEPS_BUILD: Regenerate without local dependencies. 2016-02-24 17:20:11 +00:00
auditreduce
authpf
autofs MFH 2016-04-04 23:55:32 +00:00
bhyve bhyve: consider the bogus case of a negative bar idx. 2016-05-13 14:59:02 +00:00
bhyvectl MFH 2016-01-12 14:33:17 +00:00
bhyveload MFH 2016-04-06 01:44:21 +00:00
binmiscctl Another attempt at resolving CID 1305629. The test of cmd == -1 2016-05-13 17:48:04 +00:00
bluetooth Improve performance and functionality of the bitstring(3) api 2016-05-04 22:34:11 +00:00
boot0cfg Adjust previous fix to conform to the existing style in this file. 2016-01-14 15:49:24 +00:00
boot98cfg META_MODE: Remove DEP_MACHINE from Makefile.depend files. 2015-09-25 19:44:01 +00:00
bootparamd DIRDEPS_BUILD: Regenerate without local dependencies. 2016-02-24 17:20:11 +00:00
bsdconfig Don't repeat the the word 'the' 2016-05-17 12:52:31 +00:00
bsdinstall Only set kern.geom.part.mbr.enforce_chs=0 once, instead of once per disk 2016-05-24 00:23:39 +00:00
bsnmpd Revert r299830, it has couple of fatal errors. 2016-05-18 22:02:19 +00:00
btxld Reuse our roundup2() macro instead of reinventing the wheel. 2016-04-18 17:30:33 +00:00
camdd Fix multiple Coverity Out-of-bounds access false postive issues in CAM 2016-05-24 00:57:11 +00:00
cdcontrol
chkgrp
chown Merge ^/user/ngie/release-pkg-fix-tests to unbreak how test files are installed 2016-05-04 23:20:53 +00:00
chroot
ckdist
clear_locks
config Don't free fnamebuf before we calling cfgfile_add(). This changes a 2016-05-16 04:39:16 +00:00
cpucontrol
crashinfo
cron usr.sbin: minor spelling fixes on comments. 2016-05-01 16:41:25 +00:00
crunch DIRDEPS_BUILD: Regenerate without local dependencies. 2016-02-24 17:20:11 +00:00
ctladm usr.sbin: minor spelling fixes on comments. 2016-05-01 16:41:25 +00:00
ctld Fix error message. 2016-05-19 14:45:34 +00:00
ctm Remove a link to the CTM section of the Handbook, which no longer exists. 2016-04-14 21:56:36 +00:00
daemon o -t comman line option added to the usage(). 2016-03-03 07:07:44 +00:00
dconschat Update dependencies after r291406 added libelf to libkvm. 2015-12-01 05:18:48 +00:00
devctl Add 'devctl delete' that calls device_delete_child(). 2016-04-27 16:33:17 +00:00
devinfo Use uintmax_t (typedef'd to rman_res_t type) for rman ranges. 2016-03-18 01:28:41 +00:00
digictl
diskinfo Add support for managing Shingled Magnetic Recording (SMR) drives. 2016-05-19 14:08:36 +00:00
dumpcis
editmap DIRDEPS_BUILD: Regenerate without local dependencies. 2016-02-24 17:20:11 +00:00
edquota Use strlcpy() instead of strncpy() to ensure that qup->fsname is NUL 2016-05-13 00:02:03 +00:00
eeprom META_MODE: Remove DEP_MACHINE from Makefile.depend files. 2015-09-25 19:44:01 +00:00
etcupdate Merge ^/user/ngie/release-pkg-fix-tests to unbreak how test files are installed 2016-05-04 23:20:53 +00:00
extattr Merge ^/user/ngie/release-pkg-fix-tests to unbreak how test files are installed 2016-05-04 23:20:53 +00:00
extattrctl
fdcontrol
fdformat Use NULL instead of 0 for pointers and memory allocation. 2016-04-15 02:14:11 +00:00
fdread Use NULL instead of 0 for pointers. 2016-04-14 12:46:46 +00:00
fdwrite
fifolog DIRDEPS_BUILD: Regenerate without local dependencies. 2016-02-24 17:20:11 +00:00
flowctl
fmtree Use NULL instead of 0 for pointers. 2016-04-15 03:38:58 +00:00
freebsd-update Provide a future release as an example, instead of a historical one. 2016-02-05 21:57:50 +00:00
fstyp Merge ^/user/ngie/release-pkg-fix-tests to unbreak how test files are installed 2016-05-04 23:20:53 +00:00
ftp-proxy META MODE: Update dependencies with 'the-lot' and add missing directories. 2015-12-01 05:23:19 +00:00
fwcontrol Fix a ton of speelling errors 2015-10-21 05:37:09 +00:00
getfmac
getpmac
gpioctl Fix gcc warnings about possibly uninitialized variables in gpioctl.c. 2016-03-12 15:10:30 +00:00
gssd usr.sbin: minor spelling fixes on comments. 2016-05-01 16:41:25 +00:00
gstat Update dependencies after r291406 added libelf to libkvm. 2015-12-01 05:18:48 +00:00
hyperv META MODE: Update dependencies with 'the-lot' and add missing directories. 2015-12-01 05:23:19 +00:00
i2c i2c(8): uninitialized variable (UNINIT). 2016-05-13 15:57:55 +00:00
ifmcstat
inetd Rename getline with get_line to avoid collision with getline(3) 2016-05-10 11:12:31 +00:00
iostat Fix the usr.sbin/iostat build with GCC, broken by r295768 2016-02-22 21:40:53 +00:00
iovctl Clean up repeated "All rights reserved" 2016-03-14 17:41:17 +00:00
ip6addrctl
ipfwpcap
iscsid Build iscsid(8) with ICL_KERNEL_PROXY defined by default, as required 2016-05-23 12:58:24 +00:00
jail typo 2016-05-01 16:48:03 +00:00
jexec Define which of the username options (-u/-U) to jexec(8) is the default. 2016-04-23 22:31:58 +00:00
jls Add a package for jail(8) and related utilities. 2016-01-20 17:07:13 +00:00
kbdcontrol kbdcontrol: add -P path option to add keymap search paths 2016-03-16 04:05:02 +00:00
kbdmap kbdmap: include filename when reporting fopen() failure 2015-11-27 21:27:39 +00:00
keyserv Cleanup unnecessary semicolons from utilities we all love. 2016-04-15 22:31:22 +00:00
kgmon Use NULL instead of 0 for pointers. 2016-04-14 11:41:30 +00:00
kgzip META_MODE: Remove DEP_MACHINE from Makefile.depend files. 2015-09-25 19:44:01 +00:00
kldxref Use NULL instead of 0 for pointers. 2016-05-16 01:12:56 +00:00
lastlogin
lmcconfig Use strlcpy() instead of strncpy() when copying ifname to ensure 2016-05-15 21:45:04 +00:00
lpr Rename getline with get_line to avoid collision with getline(3) 2016-05-10 11:17:19 +00:00
lptcontrol
mailstats DIRDEPS_BUILD: Regenerate without local dependencies. 2016-02-24 17:20:11 +00:00
mailwrapper
makefs Initialize date of rootNode. 2016-05-18 22:24:52 +00:00
makemap DIRDEPS_BUILD: Regenerate without local dependencies. 2016-02-24 17:20:11 +00:00
manctl
memcontrol
mergemaster All supported releases have the -m support from r186678, so remove 2015-09-29 17:54:01 +00:00
mfiutil Fix a ton of speelling errors 2015-10-21 05:37:09 +00:00
mixer mixer(8): Style: Tag no-return usage() as __dead2 2016-05-11 17:27:27 +00:00
mld6query
mlxcontrol
mount_smbfs META MODE: Update dependencies with 'the-lot' and add missing directories. 2015-12-01 05:23:19 +00:00
mountd Use MIN macro from sys/param.h. 2016-05-02 01:49:42 +00:00
moused Use macro MAX() from sys/param.h. 2016-04-22 03:55:33 +00:00
mpsutil Plug various resources leak 2016-04-20 21:32:34 +00:00
mptable Stop suggesting -grope argument when -grope argument was actually given 2015-10-22 21:13:35 +00:00
mptutil Fix multiple Coverity Out-of-bounds access false postive issues in CAM 2016-05-24 00:57:11 +00:00
mtest mtest: Prevent access to uninitialized value. 2016-04-01 01:35:52 +00:00
nandsim usr.sbin: minor spelling fixes on comments. 2016-05-01 16:41:25 +00:00
nandtool META MODE: Connect MK_NAND directories. 2015-12-02 05:31:01 +00:00
ndiscvt Remove the old depend (mkdep) code and make FAST_DEPEND the one true way. 2016-03-30 23:50:23 +00:00
ndp Fix indent after r292333. 2015-12-19 09:18:01 +00:00
newsyslog Merge ^/user/ngie/release-pkg-fix-tests to unbreak how test files are installed 2016-05-04 23:20:53 +00:00
nfscbd Cleanup unnecessary semicolons from utilities we all love. 2016-04-15 22:31:22 +00:00
nfsd Cleanup unnecessary semicolons from utilities we all love. 2016-04-15 22:31:22 +00:00
nfsdumpstate
nfsrevoke
nfsuserd Document the new "-manage-gids" option for the nfsuserd daemon. 2015-11-30 22:16:30 +00:00
ngctl ngctl dot: Drop invalid trailing semi-colon 2015-09-22 01:31:01 +00:00
nghook
nmtree Merge ^/user/ngie/release-pkg-fix-tests to unbreak how test files are installed 2016-05-04 23:20:53 +00:00
nologin
nscd
ntp MFV r298691: 2016-04-27 07:46:38 +00:00
nvram
ofwdump DIRDEPS_BUILD: Update dependencies. 2015-12-07 23:53:01 +00:00
pc-sysinstall dd report short write as error, so don't halt on it. 2016-03-12 23:04:10 +00:00
pciconf Don't repeat the the word 'the' 2016-05-17 12:52:31 +00:00
periodic Better document security_show_{success,info,badconfig} in /etc/periodic.conf 2016-05-21 02:14:11 +00:00
pkg Remove some unneeded headers 2016-01-13 17:59:12 +00:00
pmcannotate
pmccontrol Use macro MAX() from sys/param.h. 2016-04-22 05:07:59 +00:00
pmcstat pmcstat: minor spelling fixes. 2016-05-01 16:40:56 +00:00
pmcstudy pmcstudy.8: minor "efficiency" fix. 2016-05-03 22:20:55 +00:00
pnpinfo META_MODE: Remove DEP_MACHINE from Makefile.depend files. 2015-09-25 19:44:01 +00:00
portsnap Cleanup unnecessary semicolons from utilities we all love. 2016-04-15 22:31:22 +00:00
powerd Directly set the NONBLOCK flags when creating the socket 2016-05-10 11:18:53 +00:00
ppp Don't walk off the end of the array when proto isn't explicitly 2016-05-16 23:47:08 +00:00
pppctl
praliases DIRDEPS_BUILD: Regenerate without local dependencies. 2016-02-24 17:20:11 +00:00
praudit
procctl
pstat Update dependencies after r291406 added libelf to libkvm. 2015-12-01 05:18:48 +00:00
pw Merge ^/user/ngie/release-pkg-fix-tests to unbreak how test files are installed 2016-05-04 23:20:53 +00:00
pwd_mkdb Following revision r295924, the changes to a db file should be fsynced 2016-02-23 15:28:13 +00:00
quot quot: make use of our rounddown() macro when <sys/param.h> is available. 2016-05-02 02:13:22 +00:00
quotaon
rarpd When clearing rtmsg, pass &rtmsg to bzero() instead of the address of 2016-05-17 04:03:45 +00:00
repquota
rip6query
rmt Use NULL instead of 0 for pointers. 2016-04-14 12:25:00 +00:00
route6d Use strlcpy() instead of strncpy() when copying ifname to ensure 2016-05-15 22:31:03 +00:00
rpc.lockd Actually use the loop interation limit so carefully computed on the 2016-05-16 23:00:48 +00:00
rpc.statd Set ai2 to NULL in in find_host() before the loop and after calling 2016-05-16 23:29:04 +00:00
rpc.umntall
rpc.yppasswdd Wrap EXPAND(..) macro with a do-while(0) loop and put a single statement on each line 2016-05-22 19:06:38 +00:00
rpc.ypupdated DIRDEPS_BUILD: Regenerate without local dependencies. 2016-02-24 17:20:11 +00:00
rpc.ypxfrd DIRDEPS_BUILD: Regenerate without local dependencies. 2016-02-24 17:20:11 +00:00
rpcbind Merge ^/user/ngie/release-pkg-fix-tests to unbreak how test files are installed 2016-05-04 23:20:53 +00:00
rrenumd DIRDEPS_BUILD: Regenerate without local dependencies. 2016-02-24 17:20:11 +00:00
rtadvctl
rtadvd Use strlcpy() instead of strncpy() when copying ifname to ensure 2016-05-15 22:06:21 +00:00
rtprio
rtsold Use strlcpy() instead of strncpy() when copying ifname to ensure 2016-05-15 22:17:41 +00:00
rwhod Create a rcmds package. 2016-01-21 17:33:31 +00:00
sa Merge ^/user/ngie/release-pkg-fix-tests to unbreak how test files are installed 2016-05-04 23:20:53 +00:00
sendmail MFH 2016-03-02 16:14:46 +00:00
service Add an additional check to service(8) -e incase rcvar is blank 2015-09-08 22:50:17 +00:00
services_mkdb Replace fparseln(3) with getline(3) to remove dependency on libutil 2016-05-09 20:04:22 +00:00
sesutil Plug memory leak 2016-04-20 21:37:32 +00:00
setfib
setfmac
setpmac
sicontrol
smbmsg
snapinfo
spkrtest
spray
syslogd syslogd: Enable repeated line compression for lines of any length. 2016-01-27 16:17:15 +00:00
sysrc jls(1) -> jls(8) 2016-02-29 17:30:34 +00:00
tcpdchk Use LIBEXECDIR for /usr/libexec. 2015-11-26 01:14:40 +00:00
tcpdmatch Use LIBEXECDIR for /usr/libexec. 2015-11-26 01:14:40 +00:00
tcpdrop
tcpdump Update dependencies. 2016-02-26 22:14:15 +00:00
tests Merge ^/user/ngie/release-pkg-fix-tests to unbreak how test files are installed 2016-05-04 23:20:53 +00:00
timed Undo the bogus gethostname() change from r299709. 2016-05-14 04:29:13 +00:00
traceroute DIRDEPS_BUILD: Regenerate without local dependencies. 2016-02-24 17:20:11 +00:00
traceroute6 traceroute6(8): use NULL instead of zero for initializing a pointer. 2016-05-12 02:05:50 +00:00
trpt
tzsetup Use NULL instead of 0 for pointers. 2016-04-15 04:10:47 +00:00
uathload Implement suggestion by jhb@ to have _PATH_FIRMWARE instead of hard 2016-03-23 04:18:57 +00:00
uefisign META MODE: Update dependencies with 'the-lot' and add missing directories. 2015-12-01 05:23:19 +00:00
ugidfw
uhsoctl Prevent use-after-free with ctx->ns in set_nameservers(..), which could occur 2015-12-22 05:57:23 +00:00
unbound MFH 2016-03-14 18:54:29 +00:00
usbconfig
usbdump Reuse our roundup2() macro instead of reinventing the wheel. 2016-04-18 17:30:33 +00:00
utx
vidcontrol Add "vidcontrol -i active", to print out active vty number, 2016-01-19 13:09:20 +00:00
vigr META MODE: Update dependencies with 'the-lot' and add missing directories. 2015-12-01 05:23:19 +00:00
vipw
wake
watch Use strlcpy() when the string is expected to be nul-terminated. 2015-10-06 22:49:25 +00:00
watchdogd Fix typo. 2016-02-29 17:40:37 +00:00
wlandebug
wlconfig META_MODE: Remove DEP_MACHINE from Makefile.depend files. 2015-09-25 19:44:01 +00:00
wpa Update hostapd/wpa_supplicant to version 2.5. 2015-10-18 21:38:25 +00:00
yp_mkdb
ypbind Use strlcpy() instead of strncpy() when copying to dom_domain to 2016-05-12 21:35:40 +00:00
ypldap Simplify overengineered and buggy code that looked like as if it did 2016-05-16 02:44:22 +00:00
yppoll Update META_MODE dependencies. 2015-09-17 05:06:34 +00:00
yppush DIRDEPS_BUILD: Regenerate without local dependencies. 2016-02-24 17:20:11 +00:00
ypserv DIRDEPS_BUILD: Regenerate without local dependencies. 2016-02-24 17:20:11 +00:00
ypset Rename YP to NIS in the manpages. 2015-09-03 07:18:52 +00:00
zic Use more appropriate ${SHAREDIR} rather than /usr/share. 2015-10-27 23:35:02 +00:00
zonectl Add support for managing Shingled Magnetic Recording (SMR) drives. 2016-05-19 14:08:36 +00:00
zzz
Makefile Add support for managing Shingled Magnetic Recording (SMR) drives. 2016-05-19 14:08:36 +00:00
Makefile.amd64 Make the building of libsmb and mount_smbfs unconditional, now that r292552 2015-12-21 17:41:08 +00:00
Makefile.arm Make the building of libsmb and mount_smbfs unconditional, now that r292552 2015-12-21 17:41:08 +00:00
Makefile.arm64 arm64: build usr.sbin/acpi subdirectory 2015-11-08 20:56:04 +00:00
Makefile.i386 Make the building of libsmb and mount_smbfs unconditional, now that r292552 2015-12-21 17:41:08 +00:00
Makefile.inc
Makefile.mips Document why we use -z nonexecstack in the Makefile since it 2015-11-21 16:37:11 +00:00
Makefile.powerpc Make the building of libsmb and mount_smbfs unconditional, now that r292552 2015-12-21 17:41:08 +00:00
Makefile.sparc64 Make the building of libsmb and mount_smbfs unconditional, now that r292552 2015-12-21 17:41:08 +00:00