]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
Fix acpidump CID 1011278 (Buffer not null terminated) and other issues
authortruckman <truckman@FreeBSD.org>
Tue, 24 May 2016 23:36:43 +0000 (23:36 +0000)
committertruckman <truckman@FreeBSD.org>
Tue, 24 May 2016 23:36:43 +0000 (23:36 +0000)
commit4b5433e33a1d4f5587905894fb1c76a5f99a49d4
treea17612c400de342efbf56e5c5750d03561072f15
parent8d9f7ad55199db2d543169880be2772bde86fe18
Fix acpidump CID 1011278 (Buffer not null terminated) and other issues

Coverity reports that a buffer used for temporary file generation
might not be NUL terminated by strncpy().  This is probably not
true because the input gets passed through realpath(), but if the
path name is sufficiently long the name could be truncated and cause
other problems.  The code for generating the temp file names is
also overly complex.  Instead of a bunch of calls to strncpy() and
and strncat(), simplify the code by using snprintf() and add checks
for unexpected truncation.

The output file created by iasl -d is predictable.  Fix this by
using  mkdtemp() to create a directory to hold the iasl input and
output files.

Check the return values of more syscalls.

Reported by: Coverity
CID: 1011278
Reviewed by: jkim
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D6360
usr.sbin/acpi/acpidump/acpi.c