Commit 93615472 authored by Erkki Seppälä's avatar Erkki Seppälä Committed by Ulrich Sibiller

Xrm: Handle the extremely unlikely situation of fstat failing

Tracked variable "size" was passed to a negative sink. Reviewed-by: 's avatarAlan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: 's avatarAnder Conselvan de Oliveira <ander.conselvan-de-oliveira@nokia.com> Signed-off-by: 's avatarErkki Seppälä <erkki.seppala@vincit.fi> Signed-off-by: 's avatarAlan Coopersmith <alan.coopersmith@oracle.com> (cherry picked from commit be3e6c205d94dedc1cdebf5d17b987f0f828377a) Backported-to-NX-by: 's avatarUlrich Sibiller <uli42@gmx.de>
parent 051d521f
...@@ -1594,6 +1594,12 @@ ReadInFile(_Xconst char *filename) ...@@ -1594,6 +1594,12 @@ ReadInFile(_Xconst char *filename)
*/ */
GetSizeOfFile(fd, size); GetSizeOfFile(fd, size);
/* There might have been a problem trying to stat a file */
if (size == -1) {
close (fd);
return (char *)NULL;
}
if (!(filebuf = Xmalloc(size + 1))) { /* leave room for '\0' */ if (!(filebuf = Xmalloc(size + 1))) { /* leave room for '\0' */
close(fd); close(fd);
return (char *)NULL; return (char *)NULL;
......
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