summaryrefslogtreecommitdiff
path: root/test/src
diff options
context:
space:
mode:
authorJeremy Harris <jgh146exb@wizmail.org>2016-11-06 23:10:34 +0000
committerJeremy Harris <jgh146exb@wizmail.org>2016-11-08 15:35:34 +0000
commit5ddc9771fa4d7861d3e5bfd6ea30c054883eaf40 (patch)
treefc2bd51ab9ea6b6685ea898400d2ebdc3a0faaa7 /test/src
parentdd7b74e90a96eaf109796d8f9499578571a1572c (diff)
Ensure socket is nonblocking before draining. Bug 1914
Diffstat (limited to 'test/src')
-rw-r--r--test/src/client.c29
-rw-r--r--test/src/server.c2
2 files changed, 23 insertions, 8 deletions
diff --git a/test/src/client.c b/test/src/client.c
index 5e6b6472a..2b73098f5 100644
--- a/test/src/client.c
+++ b/test/src/client.c
@@ -24,6 +24,7 @@ ripped from the openssl ocsp and s_client utilities. */
#include <netinet/in_systm.h>
#include <netinet/in.h>
#include <netinet/ip.h>
+#include <netinet/tcp.h>
#include <netdb.h>
#include <arpa/inet.h>
@@ -897,9 +898,13 @@ while (fgets(CS outbuffer, sizeof(outbuffer), stdin) != NULL)
/* Expect incoming */
- if (strncmp(CS outbuffer, "??? ", 4) == 0)
+ if ( strncmp(CS outbuffer, "???", 3) == 0
+ && (outbuffer[3] == ' ' || outbuffer[3] == '*')
+ )
{
unsigned char *lineptr;
+ unsigned exp_eof = outbuffer[3] == '*';
+
printf("%s\n", outbuffer);
if (*inptr == 0) /* Refill input buffer */
@@ -921,15 +926,27 @@ while (fgets(CS outbuffer, sizeof(outbuffer), stdin) != NULL)
}
if (rc < 0)
- {
+ {
printf("Read error %s\n", strerror(errno));
- exit(81) ;
- }
+ exit(81);
+ }
else if (rc == 0)
+ if (exp_eof)
+ {
+ printf("Expected EOF read\n");
+ continue;
+ }
+ else
+ {
+ printf("Enexpected EOF read\n");
+ close(sock);
+ exit(80);
+ }
+ else if (exp_eof)
{
- printf("Unexpected EOF read\n");
+ printf("Expected EOF not read\n");
close(sock);
- exit(80);
+ exit(74);
}
else
{
diff --git a/test/src/server.c b/test/src/server.c
index 4a48965e2..26fcaf070 100644
--- a/test/src/server.c
+++ b/test/src/server.c
@@ -397,7 +397,6 @@ else
sin4.sin_addr.s_addr = (S_ADDR_TYPE)INADDR_ANY;
sin4.sin_port = htons(port);
if (bind(listen_socket[i], (struct sockaddr *)&sin4, sizeof(sin4)) < 0)
- {
if (listen_socket[v6n] < 0 || errno != EADDRINUSE)
{
printf("IPv4 socket bind() failed: %s\n", strerror(errno));
@@ -408,7 +407,6 @@ else
close(listen_socket[i]);
listen_socket[i] = -1;
}
- }
}
}
}