Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/external/bsd/blacklist/test more bugs
details: https://anonhg.NetBSD.org/src/rev/950a8b0a36a1
branches: trunk
changeset: 335722:950a8b0a36a1
user: christos <christos%NetBSD.org@localhost>
date: Thu Jan 22 05:03:52 2015 +0000
description:
more bugs
diffstat:
external/bsd/blacklist/test/Makefile | 4 +++-
external/bsd/blacklist/test/cltest.c | 15 +++++++++++----
external/bsd/blacklist/test/srvtest.c | 23 ++++++++++++++---------
3 files changed, 28 insertions(+), 14 deletions(-)
diffs (143 lines):
diff -r dd851ce0f582 -r 950a8b0a36a1 external/bsd/blacklist/test/Makefile
--- a/external/bsd/blacklist/test/Makefile Thu Jan 22 04:20:50 2015 +0000
+++ b/external/bsd/blacklist/test/Makefile Thu Jan 22 05:03:52 2015 +0000
@@ -1,9 +1,11 @@
-# $NetBSD: Makefile,v 1.1 2015/01/21 16:16:00 christos Exp $
+# $NetBSD: Makefile,v 1.2 2015/01/22 05:03:52 christos Exp $
MKMAN=no
PROGS=srvtest cltest
SRCS.srvtest = srvtest.c
SRCS.cltest = cltest.c
+LDADD+=-lutil
+DPADD+=${LIBUTIL}
.include <bsd.prog.mk>
diff -r dd851ce0f582 -r 950a8b0a36a1 external/bsd/blacklist/test/cltest.c
--- a/external/bsd/blacklist/test/cltest.c Thu Jan 22 04:20:50 2015 +0000
+++ b/external/bsd/blacklist/test/cltest.c Thu Jan 22 05:03:52 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cltest.c,v 1.4 2015/01/22 03:48:07 christos Exp $ */
+/* $NetBSD: cltest.c,v 1.5 2015/01/22 05:03:52 christos Exp $ */
/*-
* Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -33,7 +33,7 @@
#endif
#include <sys/cdefs.h>
-__RCSID("$NetBSD: cltest.c,v 1.4 2015/01/22 03:48:07 christos Exp $");
+__RCSID("$NetBSD: cltest.c,v 1.5 2015/01/22 05:03:52 christos Exp $");
#include <sys/types.h>
#include <sys/socket.h>
@@ -45,6 +45,9 @@
#include <unistd.h>
#include <stdlib.h>
#include <err.h>
+#ifdef HAVE_UTIL_H
+#include <util.h>
+#endif
static __dead void
usage(int c)
@@ -78,7 +81,7 @@
s->sin_port = p;
}
#ifdef HAVE_STRUCT_SOCKADDR_SA_LEN
- ss->ss_len = *slen;
+ ss->ss_len = (uint8_t)*slen;
#endif
if (c == -1)
err(EXIT_FAILURE, "Invalid address `%s'", a);
@@ -95,8 +98,9 @@
int type = SOCK_STREAM;
in_port_t port = 6161;
socklen_t slen;
+ char buf[128];
- while ((c = getopt(argc, argv, "a:m:p:u")) == -1) {
+ while ((c = getopt(argc, argv, "a:m:p:u")) != -1) {
switch (c) {
case 'a':
addr = optarg;
@@ -120,11 +124,14 @@
if ((sfd = socket(AF_INET, type, 0)) == -1)
err(EXIT_FAILURE, "socket");
+ sockaddr_snprintf(buf, sizeof(buf), "%a:%p", (const void *)&ss);
+ printf("connecting to: %s\n", buf);
if (connect(sfd, (const void *)&ss, slen) == -1)
err(EXIT_FAILURE, "connect");
size_t len = strlen(msg) + 1;
if (write(sfd, msg, len) != (ssize_t)len)
err(EXIT_FAILURE, "write");
+ sleep(10);
return 0;
}
diff -r dd851ce0f582 -r 950a8b0a36a1 external/bsd/blacklist/test/srvtest.c
--- a/external/bsd/blacklist/test/srvtest.c Thu Jan 22 04:20:50 2015 +0000
+++ b/external/bsd/blacklist/test/srvtest.c Thu Jan 22 05:03:52 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: srvtest.c,v 1.7 2015/01/22 04:13:04 christos Exp $ */
+/* $NetBSD: srvtest.c,v 1.8 2015/01/22 05:03:52 christos Exp $ */
/*-
* Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -33,7 +33,7 @@
#endif
#include <sys/cdefs.h>
-__RCSID("$NetBSD: srvtest.c,v 1.7 2015/01/22 04:13:04 christos Exp $");
+__RCSID("$NetBSD: srvtest.c,v 1.8 2015/01/22 05:03:52 christos Exp $");
#include <sys/types.h>
#include <sys/socket.h>
@@ -94,25 +94,30 @@
s6->sin6_port = p;
}
#ifdef HAVE_STRUCT_SOCKADDR_SA_LEN
- ss.ss_len = slen;
+ ss.ss_len = (uint8_t)slen;
#endif
if (bind(sfd, (const void *)&ss, slen) == -1)
err(1, "bind");
- if (listen(sfd, 5) == -1)
- err(1, "listen");
+ if (type != SOCK_DGRAM)
+ if (listen(sfd, 5) == -1)
+ err(1, "listen");
return sfd;
}
static void
-handle(int sfd)
+handle(int type, int sfd)
{
struct sockaddr_storage ss;
socklen_t alen = sizeof(ss);
int afd;
- if ((afd = accept(sfd, (void *)&ss, &alen)) == -1)
- err(1, "accept");
+
+ if (type != SOCK_DGRAM) {
+ if ((afd = accept(sfd, (void *)&ss, &alen)) == -1)
+ err(1, "accept");
+ } else
+ afd = sfd;
/* Create child process */
switch (fork()) {
@@ -174,7 +179,7 @@
for (size_t i = 0; i < __arraycount(pfd); i++) {
if ((pfd[i].revents & POLLIN) == 0)
continue;
- handle(pfd[i].fd);
+ handle(type, pfd[i].fd);
}
}
}
Home |
Main Index |
Thread Index |
Old Index