From 98f28de10701245053f034e9c386133a39dcb1d9 Mon Sep 17 00:00:00 2001 From: "C. McEnroe" Date: Sat, 2 Nov 2019 18:15:50 -0400 Subject: Send an unrecognized_name alert when failing to dispatch --- dispatch.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'dispatch.c') diff --git a/dispatch.c b/dispatch.c index 71f8fc7..0c3fffa 100644 --- a/dispatch.c +++ b/dispatch.c @@ -133,6 +133,16 @@ static char *serverName(void) { return NULL; } +static const uint8_t Alert[] = { + 0x15, 0x03, 0x03, 0x00, 0x02, // TLSPlaintext + 0x02, 0x70, // Alert fatal unrecognized_name +}; + +static void alert(int sock) { + ssize_t len = send(sock, Alert, sizeof(Alert), 0); + if (len < 0) warn("send"); +} + int main(int argc, char *argv[]) { const char *host = "localhost"; const char *port = "6697"; @@ -268,6 +278,7 @@ int main(int argc, char *argv[]) { char *name = serverName(); if (!name || name[0] == '.' || name[0] == '/') { + alert(event.ptr[i].fd); eventRemove(i); continue; } @@ -288,11 +299,16 @@ int main(int argc, char *argv[]) { #else error = connect(sock, (struct sockaddr *)&addr, SUN_LEN(&addr)); #endif - if (error) warn("%s", name); - if (!error) { + if (error) { + warn("%s", name); + alert(event.ptr[i].fd); + } else { len = sendfd(sock, event.ptr[i].fd); - if (len < 0) warn("%s", name); + if (len < 0) { + warn("%s", name); + alert(event.ptr[i].fd); + } } close(sock); -- cgit 1.4.1