aboutsummaryrefslogtreecommitdiff
path: root/nx-X11
diff options
context:
space:
mode:
Diffstat (limited to 'nx-X11')
-rw-r--r--nx-X11/lib/X11/Xrm.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/nx-X11/lib/X11/Xrm.c b/nx-X11/lib/X11/Xrm.c
index e498e4e5a..6adbc0dda 100644
--- a/nx-X11/lib/X11/Xrm.c
+++ b/nx-X11/lib/X11/Xrm.c
@@ -62,6 +62,7 @@ from The Open Group.
#endif
#include <nx-X11/Xos.h>
#include <sys/stat.h>
+#include <limits.h>
#include "Xresinternal.h"
#include "Xresource.h"
@@ -1595,11 +1596,12 @@ ReadInFile(_Xconst char *filename)
*/
{
struct stat status_buffer;
- if ( (fstat(fd, &status_buffer)) == -1 ) {
+ if ( ((fstat(fd, &status_buffer)) == -1 ) ||
+ (status_buffer.st_size >= INT_MAX) ) {
close (fd);
return (char *)NULL;
} else
- size = status_buffer.st_size;
+ size = (int) status_buffer.st_size;
}
if (!(filebuf = Xmalloc(size + 1))) { /* leave room for '\0' */