Commit 8468165a authored by Alan Coopersmith's avatar Alan Coopersmith Committed by Ulrich Sibiller

integer truncation in _XimParseStringFile() [CVE-2013-1981 8/13]

Called from _XimCreateDefaultTree() which uses getenv("XCOMPOSEFILE") to specify filename. If the size of off_t is larger than the size of unsigned long (as in 32-bit builds with large file flags), a file larger than 4 gigs could have its size truncated, leading to data from that file being written past the end of the undersized buffer allocated for it. While configure.ac does not use AC_SYS_LARGEFILE to set large file mode, builders may have added the large file compilation flags to CFLAGS on their own. size is left limited to an int, because if your Xim file is larger than 2gb, you're doing it wrong. Reported-by: 's avatarIlja Van Sprundel <ivansprundel@ioactive.com> Signed-off-by: 's avatarAlan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: 's avatarMatthieu Herrb <matthieu.herrb@laas.fr> Signed-off-by: 's avatarJulien Cristau <jcristau@debian.org> Backported-to-NX-by: 's avatarUlrich Sibiller <uli42@gmx.de>
parent 00d7a2e5
......@@ -41,6 +41,7 @@ OR PERFORMANCE OF THIS SOFTWARE.
#include "Ximint.h"
#include <sys/stat.h>
#include <stdio.h>
#include <limits.h>
#define XLC_BUFSIZE 256
......@@ -674,6 +675,8 @@ _XimParseStringFile(
if (fstat (fileno (fp), &st) != -1) {
unsigned long size = (unsigned long) st.st_size;
if (st.st_size >= INT_MAX)
return;
if (size <= sizeof tb) tbp = tb;
else tbp = malloc (size);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment