freebsd-dev/bin
Don Lewis 63a4675d89 Hopefully fix Coverity CID 1008328 (Out-of-bounds write) in /bin/sh.
Replace the magic constant 127 in the loop interation count with
"PROMPTLEN - 1".

gethostname() is not guaranteed to NUL terminate the destination
string if it is too short. Decrease the length passed to gethostname()
by one, and add a NUL at the end of the buffer to make sure the
following loop to find the end of the name properly terminates.

The default: case is the likely cause of Coverity CID 1008328.  If
i is 126 at the top of the loop interation where the default case
is triggered, i will be incremented to 127 by the default case,
then incremented to 128 at the top of the loop before being compared
to 127 (PROMPTLENT - 1) and terminating the loop. Then the NUL
termination code after the loop will write to ps[128].  Fix by
checking for overflow before incrementing the index and storing the
second character in the buffer.

These fixes are not guaranteed to satisfy Coverity. The code that
increments i in the 'h'/'H' and 'w'/'W' cases may be beyond its
capability to analyze, but the code appears to be safe.

Reported by:	Coverity
CID:		1008328
Reviewed by:	jilles, cem
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D6482
2016-05-23 01:01:23 +00:00
..
cat Merge ^/user/ngie/release-pkg-fix-tests to unbreak how test files are installed 2016-05-04 23:20:53 +00:00
chflags Explicitly add unmarked bin/ binaries to the runtime package. 2016-02-09 16:58:50 +00:00
chio Explicitly add unmarked bin/ binaries to the runtime package. 2016-02-09 16:58:50 +00:00
chmod Explicitly add unmarked bin/ binaries to the runtime package. 2016-02-09 16:58:50 +00:00
cp Explicitly add unmarked bin/ binaries to the runtime package. 2016-02-09 16:58:50 +00:00
csh DIRDEPS_BUILD: Run the staged bootstrap-tools version of build-tools. 2016-05-09 22:21:09 +00:00
date Merge ^/user/ngie/release-pkg-fix-tests to unbreak how test files are installed 2016-05-04 23:20:53 +00:00
dd Merge ^/user/ngie/release-pkg-fix-tests to unbreak how test files are installed 2016-05-04 23:20:53 +00:00
df Explicitly add unmarked bin/ binaries to the runtime package. 2016-02-09 16:58:50 +00:00
domainname Explicitly add unmarked bin/ binaries to the runtime package. 2016-02-09 16:58:50 +00:00
echo Explicitly add unmarked bin/ binaries to the runtime package. 2016-02-09 16:58:50 +00:00
ed ed(1): simplify by using arc4random_buf(). 2016-05-21 00:45:42 +00:00
expr Merge ^/user/ngie/release-pkg-fix-tests to unbreak how test files are installed 2016-05-04 23:20:53 +00:00
freebsd-version MFH 2016-04-04 23:55:32 +00:00
getfacl Explicitly add unmarked bin/ binaries to the runtime package. 2016-02-09 16:58:50 +00:00
hostname Explicitly add unmarked bin/ binaries to the runtime package. 2016-02-09 16:58:50 +00:00
kenv Explicitly add unmarked bin/ binaries to the runtime package. 2016-02-09 16:58:50 +00:00
kill Explicitly add unmarked bin/ binaries to the runtime package. 2016-02-09 16:58:50 +00:00
ln Explicitly add unmarked bin/ binaries to the runtime package. 2016-02-09 16:58:50 +00:00
ls Merge ^/user/ngie/release-pkg-fix-tests to unbreak how test files are installed 2016-05-04 23:20:53 +00:00
mkdir Explicitly add unmarked bin/ binaries to the runtime package. 2016-02-09 16:58:50 +00:00
mv Merge ^/user/ngie/release-pkg-fix-tests to unbreak how test files are installed 2016-05-04 23:20:53 +00:00
pax Rename getline with get_line to avoid collision with getline(3) 2016-05-10 11:11:23 +00:00
pkill Merge ^/user/ngie/release-pkg-fix-tests to unbreak how test files are installed 2016-05-04 23:20:53 +00:00
ps Use NULL instead of 0 for pointers. 2016-04-19 00:40:43 +00:00
pwait Explicitly add unmarked bin/ binaries to the runtime package. 2016-02-09 16:58:50 +00:00
pwd Explicitly add unmarked bin/ binaries to the runtime package. 2016-02-09 16:58:50 +00:00
rcp MFH 2016-04-12 17:00:13 +00:00
realpath Explicitly add unmarked bin/ binaries to the runtime package. 2016-02-09 16:58:50 +00:00
rm Explicitly add unmarked bin/ binaries to the runtime package. 2016-02-09 16:58:50 +00:00
rmail MFH 2016-03-02 16:14:46 +00:00
rmdir Explicitly add unmarked bin/ binaries to the runtime package. 2016-02-09 16:58:50 +00:00
setfacl Explicitly add unmarked bin/ binaries to the runtime package. 2016-02-09 16:58:50 +00:00
sh Hopefully fix Coverity CID 1008328 (Out-of-bounds write) in /bin/sh. 2016-05-23 01:01:23 +00:00
sleep Merge ^/user/ngie/release-pkg-fix-tests to unbreak how test files are installed 2016-05-04 23:20:53 +00:00
stty Explicitly add unmarked bin/ binaries to the runtime package. 2016-02-09 16:58:50 +00:00
sync Explicitly add unmarked bin/ binaries to the runtime package. 2016-02-09 16:58:50 +00:00
test Merge ^/user/ngie/release-pkg-fix-tests to unbreak how test files are installed 2016-05-04 23:20:53 +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
uuidgen Explicitly add unmarked bin/ binaries to the runtime package. 2016-02-09 16:58:50 +00:00
Makefile Start using the fact that SUBDIR.yes is added to SUBDIR 2015-10-05 21:41:55 +00:00
Makefile.inc Use src.opts.mk in preference to bsd.own.mk except where we need stuff 2014-05-06 04:22:01 +00:00