freebsd-dev/lib
Colin Percival c6a96a8441 Give a less silly response to a silly request.
Prior to this commit, fread/fwrite calls with size * nmemb > SIZE_MAX
were handled by reading or writing (size_t)(size * nmemb) bytes; for
example, on 32-bit platforms, fread(ptr, 641, 6700417, f) would read 1
byte and indicate that the requested 6700417 blocks had been read.

This commit adds a check for such integer overflows, and treats them as
if an overly large request was passed to read/write; i.e., it sets errno
to EINVAL, sets the error indicator on the file, and returns a short
object count (0, to be specific).

The overflow check involves an integer division, so as a performance
optimization we check first to see if both size and nmemb are less than
2^16; if they are, no overflow is possible and we avoid the division.
We assume here that size_t is at least 32 bits; this appears to be true
on all platforms FreeBSD supports.

Although this commit fixes an integer overflow, it is not likely to have
any security implications, since any program which would be affected by
this bug fix is quite clearly already very confused.

Reviewed by:	kib
MFC after:	1 month
2010-01-10 14:30:30 +00:00
..
bind Update to BIND 9.6.1-P2. The vulnerability this is designed to fix is 2009-11-30 03:38:34 +00:00
csu Build lib/ with WARNS=6 by default. 2010-01-02 09:58:07 +00:00
libalias Bump the version of all non-symbol-versioned shared libraries in 2009-07-19 17:25:24 +00:00
libarchive Build lib/ with WARNS=6 by default. 2010-01-02 09:58:07 +00:00
libauditd Build lib/ with WARNS=6 by default. 2010-01-02 09:58:07 +00:00
libautofs Build lib/ with WARNS=6 by default. 2010-01-02 09:58:07 +00:00
libbegemot Build lib/ with WARNS=6 by default. 2010-01-02 09:58:07 +00:00
libbluetooth Fix typo in bluetooth.3 2009-10-26 17:27:30 +00:00
libbsm Build lib/ with WARNS=6 by default. 2010-01-02 09:58:07 +00:00
libbsnmp Bump the version of all non-symbol-versioned shared libraries in 2009-07-19 17:25:24 +00:00
libbz2 Build lib/ with WARNS=6 by default. 2010-01-02 09:58:07 +00:00
libc Give a less silly response to a silly request. 2010-01-10 14:30:30 +00:00
libc_r Use, in uncovered part, the END() macro in order to improve debugging. 2009-05-25 14:37:10 +00:00
libcalendar Build lib/ with WARNS=6 by default. 2010-01-02 09:58:07 +00:00
libcam Build lib/ with WARNS=6 by default. 2010-01-02 09:58:07 +00:00
libcom_err
libcompat Build lib/ with WARNS=6 by default. 2010-01-02 09:58:07 +00:00
libcrypt Build lib/ with WARNS=6 by default. 2010-01-02 09:58:07 +00:00
libdevinfo Build lib/ with WARNS=6 by default. 2010-01-02 09:58:07 +00:00
libdevstat Build lib/ with WARNS=6 by default. 2010-01-02 09:58:07 +00:00
libdisk Disable a check on a disk size because it's too strict. This change is 2009-09-21 04:04:02 +00:00
libdwarf Build lib/ with WARNS=6 by default. 2010-01-02 09:58:07 +00:00
libedit Build lib/ with WARNS=6 by default. 2010-01-02 09:58:07 +00:00
libelf Build lib/ with WARNS=6 by default. 2010-01-02 09:58:07 +00:00
libexpat Build lib/ with WARNS=6 by default. 2010-01-02 09:58:07 +00:00
libfetch Fix a socket leak in ftp_request() after that a connection is established. 2009-11-25 14:57:07 +00:00
libftpio Build lib/ with WARNS=6 by default. 2010-01-02 09:58:07 +00:00
libgeom Add missing `void' keyword. 2009-12-31 01:37:26 +00:00
libgpib Build lib/ with WARNS=6 by default. 2010-01-02 09:58:07 +00:00
libgssapi Build lib/ with WARNS=6 by default. 2010-01-02 09:58:07 +00:00
libipsec Build lib/ with WARNS=6 by default. 2010-01-02 09:58:07 +00:00
libipx Build lib/ with WARNS=6 by default. 2010-01-02 09:58:07 +00:00
libjail Build lib/ with WARNS=6 by default. 2010-01-02 09:58:07 +00:00
libkiconv Build lib/ with WARNS=6 by default. 2010-01-02 09:58:07 +00:00
libkse Bump the version of all non-symbol-versioned shared libraries in 2009-07-19 17:25:24 +00:00
libkvm Build lib/ with WARNS=6 by default. 2010-01-02 09:58:07 +00:00
libmagic Build lib/ with WARNS=6 by default. 2010-01-02 09:58:07 +00:00
libmd Build lib/ with WARNS=6 by default. 2010-01-02 09:58:07 +00:00
libmemstat Bump the version of all non-symbol-versioned shared libraries in 2009-07-19 17:25:24 +00:00
libmilter Build lib/ with WARNS=6 by default. 2010-01-02 09:58:07 +00:00
libmp Build lib/ with WARNS=6 by default. 2010-01-02 09:58:07 +00:00
libncp Build lib/ with WARNS=6 by default. 2010-01-02 09:58:07 +00:00
libnetgraph bring the NGM_IPFW_COOKIE back into ng_ipfw.h, libnetgraph expects 2009-12-28 12:29:13 +00:00
libngatm Build lib/ with WARNS=6 by default. 2010-01-02 09:58:07 +00:00
libopie Build lib/ with WARNS=6 by default. 2010-01-02 09:58:07 +00:00
libpam Build lib/ with WARNS=6 by default. 2010-01-02 09:58:07 +00:00
libpcap Build lib/ with WARNS=6 by default. 2010-01-02 09:58:07 +00:00
libpmc Build lib/ with WARNS=6 by default. 2010-01-02 09:58:07 +00:00
libproc Build lib/ with WARNS=6 by default. 2010-01-02 09:58:07 +00:00
libradius Build lib/ with WARNS=6 by default. 2010-01-02 09:58:07 +00:00
librpcsec_gss Build lib/ with WARNS=6 by default. 2010-01-02 09:58:07 +00:00
librpcsvc Use ANSI function declarations in librpcsvc. 2009-02-26 20:32:11 +00:00
librt Build lib/ with WARNS=6 by default. 2010-01-02 09:58:07 +00:00
libsbuf Build lib/ with WARNS=6 by default. 2010-01-02 09:58:07 +00:00
libsdp Bump the version of all non-symbol-versioned shared libraries in 2009-07-19 17:25:24 +00:00
libsm Build lib/ with WARNS=6 by default. 2010-01-02 09:58:07 +00:00
libsmb Bump the version of all non-symbol-versioned shared libraries in 2009-07-19 17:25:24 +00:00
libsmdb Build lib/ with WARNS=6 by default. 2010-01-02 09:58:07 +00:00
libsmutil Build lib/ with WARNS=6 by default. 2010-01-02 09:58:07 +00:00
libstand Implement the fo_readdir method. This does not support long 2010-01-09 22:33:34 +00:00
libtacplus Build lib/ with WARNS=6 by default. 2010-01-02 09:58:07 +00:00
libtelnet Rename all symbols in libmp(3) to mp_*, just like Solaris. 2009-02-26 21:43:15 +00:00
libthr Merge r195129 from project/mips to head by hand: 2010-01-09 00:07:47 +00:00
libthread_db Build lib/ with WARNS=6 by default. 2010-01-02 09:58:07 +00:00
libufs Build lib/ with WARNS=6 by default. 2010-01-02 09:58:07 +00:00
libugidfw Build lib/ with WARNS=6 by default. 2010-01-02 09:58:07 +00:00
libulog Build lib/ with WARNS=6 by default. 2010-01-02 09:58:07 +00:00
libusb Build lib/ with WARNS=6 by default. 2010-01-02 09:58:07 +00:00
libusbhid Bump the version of all non-symbol-versioned shared libraries in 2009-07-19 17:25:24 +00:00
libutil Build lib/ with WARNS=6 by default. 2010-01-02 09:58:07 +00:00
libvgl Build lib/ with WARNS=6 by default. 2010-01-02 09:58:07 +00:00
libwrap Build lib/ with WARNS=6 by default. 2010-01-02 09:58:07 +00:00
liby Build lib/ with WARNS=6 by default. 2010-01-02 09:58:07 +00:00
libypclnt Build lib/ with WARNS=6 by default. 2010-01-02 09:58:07 +00:00
libz Build lib/ with WARNS=6 by default. 2010-01-02 09:58:07 +00:00
msun Use the documented machine constraint for SSE registers. 2009-06-11 13:59:51 +00:00
ncurses Build lib/ with WARNS=6 by default. 2010-01-02 09:58:07 +00:00
Makefile Convert pam_lastlog(8) to libulog. 2009-12-11 14:15:55 +00:00
Makefile.inc Build lib/ with WARNS=6 by default. 2010-01-02 09:58:07 +00:00