freebsd-dev/lib
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
..
atf Merge ^/user/ngie/release-pkg-fix-tests to unbreak how test files are installed 2016-05-04 23:20:53 +00:00
clang Add FREEBSD_CC_VERSION which will be used to define __FreeBSD_cc_version. 2016-05-21 01:32:20 +00:00
csu Stop dereferencing _end in crt1.c. This was only needed for brk/sbrk so is 2016-05-22 08:20:30 +00:00
lib80211 First pass through library packaging. 2016-02-04 21:16:35 +00:00
libalias Update libalias and libpam packaged files. 2016-02-05 01:03:38 +00:00
libarchive MFV r299425: 2016-05-12 10:16:16 +00:00
libauditd First pass through library packaging. 2016-02-04 21:16:35 +00:00
libbegemot First pass through library packaging. 2016-02-04 21:16:35 +00:00
libblocksruntime First pass through library packaging. 2016-02-04 21:16:35 +00:00
libbluetooth Improve performance and functionality of the bitstring(3) api 2016-05-04 22:34:11 +00:00
libbsdstat Fix off by one error in index limit calculation 2016-05-16 15:42:59 +00:00
libbsm First pass through library packaging. 2016-02-04 21:16:35 +00:00
libbsnmp Remove NO_WERROR from libbsnmp/Makefile.inc 2016-05-13 21:17:49 +00:00
libbz2 First pass through library packaging. 2016-02-04 21:16:35 +00:00
libc vfork(2): Mention some risks of calling vfork() from application code. 2016-05-22 13:32:45 +00:00
libc_nonshared Add META_MODE support. 2015-06-13 19:20:56 +00:00
libc++ MFH 2016-03-14 18:54:29 +00:00
libcalendar First pass through library packaging. 2016-02-04 21:16:35 +00:00
libcam Fix multiple Coverity Out-of-bounds access false postive issues in CAM 2016-05-24 00:57:11 +00:00
libcasper MFH 2016-04-16 02:32:12 +00:00
libclang_rt Implement (ACFLAGS|CFLAGS|CXXFLAGS).SRC globally. 2016-03-26 03:46:12 +00:00
libcom_err First pass through library packaging. 2016-02-04 21:16:35 +00:00
libcompat rexec(3): use NULL instead of zero for pointers. 2016-04-18 14:37:26 +00:00
libcompiler_rt Make armv6 hard float abi by default. Kill armv6hf. 2016-05-18 06:01:18 +00:00
libcrypt Merge ^/user/ngie/release-pkg-fix-tests to unbreak how test files are installed 2016-05-04 23:20:53 +00:00
libcuse libcuse: make more use of the howmany() macro when available. 2016-04-26 01:20:16 +00:00
libcxxrt MFH 2016-04-04 23:55:32 +00:00
libdevctl Add 'devctl delete' that calls device_delete_child(). 2016-04-27 16:33:17 +00:00
libdevinfo MFH 2016-04-04 23:55:32 +00:00
libdevstat First pass through library packaging. 2016-02-04 21:16:35 +00:00
libdpv MFH 2016-03-02 16:14:46 +00:00
libdwarf elftoolchain: Use ${SRCTOP} for the top of the FreeBSD tree 2016-04-21 12:58:29 +00:00
libedit lib: minor spelling fixes in comments. 2016-05-01 19:37:33 +00:00
libefi First pass through library packaging. 2016-02-04 21:16:35 +00:00
libelf elftoolchain: Use ${SRCTOP} for the top of the FreeBSD tree 2016-04-21 12:58:29 +00:00
libelftc Update to ELF Tool Chain r3475 2016-05-20 17:24:34 +00:00
libevent First pass through library packaging. 2016-02-04 21:16:35 +00:00
libexecinfo First pass through library packaging. 2016-02-04 21:16:35 +00:00
libexpat First pass through library packaging. 2016-02-04 21:16:35 +00:00
libfetch Use strlcpy() instead of strncpy() to copy the string returned by 2016-05-12 06:39:13 +00:00
libfigpar MFH 2016-03-02 16:14:46 +00:00
libgeom First pass through library packaging. 2016-02-04 21:16:35 +00:00
libgpio Use GPIOTOGGLE to toggle the pin state instead of read, modify and write. 2016-04-19 15:18:31 +00:00
libgssapi lib: minor spelling fixes in comments. 2016-05-01 19:37:33 +00:00
libiconv_modules META MODE: Prefer INSTALL=tools/install.sh to lessen the need for xinstall.host. 2015-11-25 19:10:28 +00:00
libipsec libipsec: use NULL instead of zero for pointers. 2016-04-18 15:08:31 +00:00
libjail First pass through library packaging. 2016-02-04 21:16:35 +00:00
libkiconv lib: minor spelling fixes in comments. 2016-05-01 19:37:33 +00:00
libkvm lib: minor spelling fixes in comments. 2016-05-01 19:37:33 +00:00
libldns First pass through library packaging. 2016-02-04 21:16:35 +00:00
liblzma First pass through library packaging. 2016-02-04 21:16:35 +00:00
libmagic MFV r299716: file 5.27 2016-05-14 08:52:37 +00:00
libmd MFH 2016-03-02 16:14:46 +00:00
libmemstat MFH 2016-02-10 04:20:39 +00:00
libmilter MFH 2016-03-02 16:14:46 +00:00
libmp libmp: Fix trivial buffer overrun 2016-05-12 03:53:20 +00:00
libmt Add the density code for LTO-7 to libmt and the mt(1) man page. 2016-05-20 19:30:52 +00:00
libnandfs First pass through library packaging. 2016-02-04 21:16:35 +00:00
libnetbsd First pass through library packaging. 2016-02-04 21:16:35 +00:00
libnetgraph First pass through library packaging. 2016-02-04 21:16:35 +00:00
libngatm First pass through library packaging. 2016-02-04 21:16:35 +00:00
libnv Merge ^/user/ngie/release-pkg-fix-tests to unbreak how test files are installed 2016-05-04 23:20:53 +00:00
libopenbsd First pass through library packaging. 2016-02-04 21:16:35 +00:00
libopie First pass through library packaging. 2016-02-04 21:16:35 +00:00
libpam Set retval in the empty password case to avoid a path through the 2016-05-16 15:32:02 +00:00
libpcap MFH 2016-03-02 16:14:46 +00:00
libpe DIRDEPS_BUILD: Update dependencies. 2016-02-16 02:14:30 +00:00
libpjdlog MFH 2016-03-02 16:14:46 +00:00
libpmc lib: minor spelling fixes in comments. 2016-05-01 19:37:33 +00:00
libproc Merge ^/user/ngie/release-pkg-fix-tests to unbreak how test files are installed 2016-05-04 23:20:53 +00:00
libprocstat First pass through library packaging. 2016-02-04 21:16:35 +00:00
libradius First pass through library packaging. 2016-02-04 21:16:35 +00:00
librpcsec_gss librpcsec_gss: remove redundant code. 2016-05-11 14:37:33 +00:00
librpcsvc MFH 2016-03-02 16:14:46 +00:00
librt Merge ^/user/ngie/release-pkg-fix-tests to unbreak how test files are installed 2016-05-04 23:20:53 +00:00
librtld_db First pass through library packaging. 2016-02-04 21:16:35 +00:00
libsbuf First pass through library packaging. 2016-02-04 21:16:35 +00:00
libsdp lib: minor spelling fixes in comments. 2016-05-01 19:37:33 +00:00
libsm MFH 2016-03-02 16:14:46 +00:00
libsmb First pass through library packaging. 2016-02-04 21:16:35 +00:00
libsmdb MFH 2016-03-02 16:14:46 +00:00
libsmutil MFH 2016-03-02 16:14:46 +00:00
libsqlite3 First pass through library packaging. 2016-02-04 21:16:35 +00:00
libstand Fix a bug in the parsing code: always use the len and not 8. 2016-05-20 05:33:26 +00:00
libstdbuf First pass through library packaging. 2016-02-04 21:16:35 +00:00
libstdthreads First pass through library packaging. 2016-02-04 21:16:35 +00:00
libsysdecode MFH 2016-04-04 23:55:32 +00:00
libtacplus First pass through library packaging. 2016-02-04 21:16:35 +00:00
libtelnet First pass through library packaging. 2016-02-04 21:16:35 +00:00
libthr Document _umtx_op(2) interface for the implementation of robust mutexes. 2016-05-19 17:40:00 +00:00
libthread_db First pass through library packaging. 2016-02-04 21:16:35 +00:00
libucl First pass through library packaging. 2016-02-04 21:16:35 +00:00
libufs libufs: Simplify generation number calculation. 2016-05-18 19:59:05 +00:00
libugidfw First pass through library packaging. 2016-02-04 21:16:35 +00:00
libulog First pass through library packaging. 2016-02-04 21:16:35 +00:00
libunbound MFH 2016-03-14 18:54:29 +00:00
libusb lib: minor spelling fixes in comments. 2016-05-01 19:37:33 +00:00
libusbhid MFH 2016-04-11 15:24:59 +00:00
libutil libutil: minor spelling fixes. 2016-05-18 15:25:45 +00:00
libvgl MFH 2016-04-13 16:19:50 +00:00
libvmmapi lib: minor spelling fixes in comments. 2016-05-01 19:37:33 +00:00
libwrap First pass through library packaging. 2016-02-04 21:16:35 +00:00
libxo Merge ^/user/ngie/release-pkg-fix-tests to unbreak how test files are installed 2016-05-04 23:20:53 +00:00
liby First pass through library packaging. 2016-02-04 21:16:35 +00:00
libypclnt MFH 2016-04-16 02:32:12 +00:00
libz MFH 2016-04-04 23:55:32 +00:00
msun Make armv6 hard float abi by default. Kill armv6hf. 2016-05-18 06:01:18 +00:00
ncurses DIRDEPS_BUILD: Run the staged bootstrap-tools version of build-tools. 2016-05-09 22:21:09 +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
Makefile MFH 2016-03-14 18:54:29 +00:00
Makefile.inc