Date: Wed, 26 Mar 2014 19:57:50 +0000 (UTC) From: Dimitry Andric <dim@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r263775 - head/contrib/gcclibs/libcpp Message-ID: <201403261957.s2QJvoW6058472@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: dim Date: Wed Mar 26 19:57:50 2014 New Revision: 263775 URL: http://svnweb.freebsd.org/changeset/base/263775 Log: Avoid "cc1: warning: is shorter than expected" when using GNU cpp in combination with dtrace scripts, which have "#!/usr/sbin/dtrace -Cs" shebang lines. This is because dtrace positions the file pointer after the shebang line, before passing the file to GNU cpp. To fix the warning, adjust the size downwards by the current position, after a bit of sanity checking. Suggested by: avg MFC after: 1 week Modified: head/contrib/gcclibs/libcpp/files.c Modified: head/contrib/gcclibs/libcpp/files.c ============================================================================== --- head/contrib/gcclibs/libcpp/files.c Wed Mar 26 19:31:33 2014 (r263774) +++ head/contrib/gcclibs/libcpp/files.c Wed Mar 26 19:57:50 2014 (r263775) @@ -546,6 +546,7 @@ static bool read_file_guts (cpp_reader *pfile, _cpp_file *file) { ssize_t size, total, count; + off_t offset; uchar *buf; bool regular; @@ -573,6 +574,21 @@ read_file_guts (cpp_reader *pfile, _cpp_ } size = file->st.st_size; + + if ((offset = lseek(file->fd, 0, SEEK_CUR)) < 0) + { + cpp_error (pfile, CPP_DL_ERROR, "%s has no current position", + file->path); + return false; + } + else if (offset > INTTYPE_MAXIMUM (ssize_t) || (ssize_t)offset > size) + { + cpp_error (pfile, CPP_DL_ERROR, "current position of %s is too large", + file->path); + return false; + } + + size -= (ssize_t)offset; } else /* 8 kilobytes is a sensible starting size. It ought to be bigger
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201403261957.s2QJvoW6058472>