devilhorns pushed a commit to branch master.

commit 9d60d6ccff3dc183393e793c6ca4926dd1aaae5b
Author: Chris Michael <[email protected]>
Date:   Mon Jul 8 07:31:50 2013 +0100

    Check return value of lseek call for errors.
    
    NB: Fixes Coverity CID 1040029
    
    Signed-off-by: Chris Michael <[email protected]>
---
 src/bin/edje/edje_cc_parse.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/bin/edje/edje_cc_parse.c b/src/bin/edje/edje_cc_parse.c
index 625e506..6950655 100644
--- a/src/bin/edje/edje_cc_parse.c
+++ b/src/bin/edje/edje_cc_parse.c
@@ -885,7 +885,17 @@ compile(void)
      }
    DBG("Opening \"%s\" for input", file_in);
 
+   /* lseek can return -1 on error. trap that return and exit so that 
+    * we do not pass malloc a -1
+    * 
+    * NB: Fixes Coverity CID 1040029 */
    size = lseek(fd, 0, SEEK_END);
+   if (size < 0)
+     {
+        ERR("Cannot read file \"%s\". %s", file_in, strerror(errno));
+        exit(-1);
+     }
+
    lseek(fd, 0, SEEK_SET);
    data = malloc(size);
    if (data && (read(fd, data, size) == size))

-- 

------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev

Reply via email to