about summary refs log tree commit diff homepage
path: root/runtime/POSIX
diff options
context:
space:
mode:
authorCristian Cadar <c.cadar@imperial.ac.uk>2016-05-27 11:42:01 +0100
committerCristian Cadar <c.cadar@imperial.ac.uk>2016-05-27 11:42:01 +0100
commit6899ea11475aca9ca60f77b746fc3b08272481e5 (patch)
tree41d768315d97f5f8c2ee12ca10f7d05de641a5b3 /runtime/POSIX
parenta8012548f2cc31e2c2283f9f500b281532aa5aa7 (diff)
downloadklee-6899ea11475aca9ca60f77b746fc3b08272481e5.tar.gz
Fixed the stub for times() not to dereference a NULL pointer when call with a NULL argument. In respose of issue https://github.com/klee/klee/issues/399
Diffstat (limited to 'runtime/POSIX')
-rw-r--r--runtime/POSIX/stubs.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/runtime/POSIX/stubs.c b/runtime/POSIX/stubs.c
index 99e2e768..b4f31bf7 100644
--- a/runtime/POSIX/stubs.c
+++ b/runtime/POSIX/stubs.c
@@ -174,10 +174,15 @@ time_t time(time_t *t) {
 
 clock_t times(struct tms *buf) {
   /* Fake */
-  buf->tms_utime = 0;
-  buf->tms_stime = 0;
-  buf->tms_cutime = 0;
-  buf->tms_cstime = 0;
+  if (!buf)
+    klee_warning("returning 0\n");
+  else {
+    klee_warning("setting all times to 0 and returning 0\n");
+    buf->tms_utime = 0;
+    buf->tms_stime = 0;
+    buf->tms_cutime = 0;
+    buf->tms_cstime = 0;
+  }
   return 0;
 }