OK @inoguchi
2018/08/19 22:44 "Theo Buehler" <[email protected]>:

> On Sun, Aug 19, 2018 at 09:53:32PM +0900, Kinichiro Inoguchi wrote:
> > I feel that "error case free" should be done in do_accept() rather than
> caller.
> > After strdup(), there are 2 "return (0)".
> > How about adding "free(*host)" before these 2 "return (0)" ?
>
> You're right, that makes more sense.
>
> > I worried that error return occurs before strdup() in do_accept().
>
> That would be harmless as name = NULL.
>
> > On Sun, Aug 19, 2018 at 10:40:55AM +0200, Theo Buehler wrote:
> > > do_accept() may strdup() the host name and store it in `name', so we
> > > need to free it before exiting. Perhaps a refactor might be more
> > > appropriate, but I'm not sure I want to touch this mess.
>
> Index: s_socket.c
> ===================================================================
> RCS file: /var/cvs/src/usr.bin/openssl/s_socket.c,v
> retrieving revision 1.9
> diff -u -p -r1.9 s_socket.c
> --- s_socket.c  7 Feb 2018 05:47:55 -0000       1.9
> +++ s_socket.c  19 Aug 2018 13:42:59 -0000
> @@ -276,11 +276,13 @@ do_accept(int acc_sock, int *sock, char
>                 if (h2 == NULL) {
>                         BIO_printf(bio_err, "gethostbyname failure\n");
>                         close(ret);
> +                       free(*host);
>                         return (0);
>                 }
>                 if (h2->h_addrtype != AF_INET) {
>                         BIO_printf(bio_err, "gethostbyname addr is not
> AF_INET\n");
>                         close(ret);
> +                       free(*host);
>                         return (0);
>                 }
>         }
>

Reply via email to