[klee-commits] [1513] added a test case where bind should fail on a non-socket descriptor

sbkim at stanford.edu sbkim at stanford.edu
Wed Mar 18 16:53:05 PDT 2009


Revision: 1513
          http://keeda.stanford.edu/viewvc/viewvc.cgi?view=rev&revision=1513
Author:   sbkim
Date:     2009-03-18 16:53:04 -0700 (Wed, 18 Mar 2009)
Log Message:
-----------
added a test case where bind should fail on a non-socket descriptor

Added Paths:
-----------
    test/SimpleModel/SocketBind.c

Added: test/SimpleModel/SocketBind.c
===================================================================
--- test/SimpleModel/SocketBind.c	                        (rev 0)
+++ test/SimpleModel/SocketBind.c	2009-03-18 23:53:04 UTC (rev 1513)
@@ -0,0 +1,39 @@
+// RUN: %llvmgcc %s -emit-llvm -O0 -c -o %t1.bc
+// RUN: %klee --with-file-model=release %t1.bc > %t.log
+// RUN: grep -q "bind() returned error: Socket operation on non-socket" %t.log
+
+#include <stdio.h>
+#include <sys/types.h> 
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <stdlib.h>
+#include <assert.h>
+#include <linux/net.h>
+#include <errno.h>
+#include <unistd.h>
+#include <sys/syscall.h>
+#include <stdio.h>
+#include <assert.h>
+#include <sys/types.h> 
+#include <sys/socket.h>
+#include <netinet/in.h>
+
+int main(int argc, char **argv) {
+  struct sockaddr_in server_addr, client_addr;
+  
+  server_addr.sin_family = AF_INET;
+  server_addr.sin_addr.s_addr = INADDR_ANY;
+  server_addr.sin_port = htons(1080);
+
+  int r = bind(STDIN_FILENO, (struct sockaddr *) &server_addr, 
+	       sizeof(server_addr));
+  if (r < 0) {
+     perror("bind() returned error");
+     exit(1);
+  } 
+
+  /* should be unreachable */
+  printf("Success\n");
+   
+  return 0;
+}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://keeda.Stanford.EDU/pipermail/klee-commits/attachments/20090318/b96d18d0/attachment.html 


More information about the klee-commits mailing list