Commit 00d7a2e5 authored by Alan Coopersmith's avatar Alan Coopersmith Committed by Ulrich Sibiller

integer overflow in ReadInFile() in Xrm.c [CVE-2013-1981 7/13]

Called from XrmGetFileDatabase() which gets called from InitDefaults() which gets the filename from getenv ("XENVIRONMENT") If file is exactly 0xffffffff bytes long (or longer and truncates to 0xffffffff, on implementations where off_t is larger than an int), then size may be set to a value which overflows causing less memory to be allocated than is written to by the following read() call. size is left limited to an int, because if your Xresources file is larger than 2gb, you're very definitely 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 0349af11
...@@ -35,11 +35,13 @@ from The Open Group. ...@@ -35,11 +35,13 @@ from The Open Group.
#include <nx-X11/Xos.h> #include <nx-X11/Xos.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <limits.h>
#define GetSizeOfFile(fd,size) \ #define GetSizeOfFile(fd,size) \
{ \ { \
struct stat status_buffer; \ struct stat status_buffer; \
if ( (fstat((fd), &status_buffer)) == -1 ) \ if ( ((fstat((fd), &status_buffer)) == -1 ) || \
(status_buffer.st_size >= INT_MAX) ) \
size = -1; \ size = -1; \
else \ else \
size = status_buffer.st_size; \ size = status_buffer.st_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