"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Stefan Sperling <stsp@stsp.name>
Subject:
remove last use of sin_len from gotwebd
To:
gameoftrees@openbsd.org
Date:
Thu, 4 Aug 2022 23:11:55 +0200

Download raw body.

Thread
  • Stefan Sperling:

    remove last use of sin_len from gotwebd

This removes the last use of sin_len from gotwebd to avoid using
it in the -portable code base.

gotwebd still works for me with both unix sockets and tcp sockets.

I don't think this assignment to sin_len is needed at all, because
sin_len is already being set via got_sockaddr_inet[6]_init() during
the configuration stage.

ok?

diff 1bdf356cbe7084e60a738fe03c98493b6eeae85d 78de8c861804ef7e5ecd3b5ab4d19327ac58d520
commit - 1bdf356cbe7084e60a738fe03c98493b6eeae85d
commit + 78de8c861804ef7e5ecd3b5ab4d19327ac58d520
blob - b8e00918c13b3d92a2fe2fb2769ca40d82a8bec6
blob + 0b020ab754c33ba525068d380e871877d551f8e5
--- gotwebd/sockets.c
+++ gotwebd/sockets.c
@@ -75,7 +75,6 @@ void	 sockets_rlimit(int);
 int	 sockets_dispatch_gotwebd(int, struct privsep_proc *, struct imsg *);
 int	 sockets_unix_socket_listen(struct privsep *, struct socket *);
 int	 sockets_create_socket(struct addresslist *, in_port_t);
-int	 sockets_socket_af(struct sockaddr_storage *, in_port_t);
 int	 sockets_accept_reserve(int, struct sockaddr *, socklen_t *, int,
 	    volatile int *);
 
@@ -290,27 +289,6 @@ done:
 	return (sock);
 }
 
-int
-sockets_socket_af(struct sockaddr_storage *ss, in_port_t port)
-{
-	switch (ss->ss_family) {
-	case AF_INET:
-		((struct sockaddr_in *)ss)->sin_port = port;
-		((struct sockaddr_in *)ss)->sin_len =
-		    sizeof(struct sockaddr_in);
-		break;
-	case AF_INET6:
-		((struct sockaddr_in6 *)ss)->sin6_port = port;
-		((struct sockaddr_in6 *)ss)->sin6_len =
-		    sizeof(struct sockaddr_in6);
-		break;
-	default:
-		return -1;
-	}
-
-	return 0;
-}
-
 void
 sockets_launch(void)
 {
@@ -558,8 +536,15 @@ sockets_create_socket(struct addresslist *al, in_port_
 	hints.ai_flags |= AI_PASSIVE;
 
 	TAILQ_FOREACH(a, al, entry) {
-		if (sockets_socket_af(&a->ss, port) == -1) {
-			log_warnx("%s: sockets_socket_af", __func__);
+		switch (a->ss.ss_family) {
+		case AF_INET:
+			((struct sockaddr_in *)(&a->ss))->sin_port = port;
+			break;
+		case AF_INET6:
+			((struct sockaddr_in6 *)(&a->ss))->sin6_port = port;
+			break;
+		default:
+			log_warnx("%s: unknown address family", __func__);
 			goto fail;
 		}