> On Thu, Aug 27, 2015 at 10:13:25AM -0600, Theo de Raadt wrote:
> > Why not strdup?
> 
> And now with strdup() as suggested by Theo.

ok, because such style is not really a leak.

> Index: usr.sbin/syslogd/syslogd.c
> ===================================================================
> RCS file: /data/mirror/openbsd/cvs/src/usr.sbin/syslogd/syslogd.c,v
> retrieving revision 1.178
> diff -u -p -r1.178 syslogd.c
> --- usr.sbin/syslogd/syslogd.c        25 Aug 2015 17:14:16 -0000      1.178
> +++ usr.sbin/syslogd/syslogd.c        27 Aug 2015 16:28:22 -0000
> @@ -393,12 +393,16 @@ main(int argc, char *argv[])
>                       path_ctlsock = optarg;
>                       break;
>               case 'T':               /* allow tcp and listen on address */
> -                     if (loghost_parse(optarg, NULL, &listen_host,
> -                         &listen_port) == -1)
> +                     if ((p = strdup(optarg)) == NULL)
> +                             err(1, "strdup listen address");
> +                     if (loghost_parse(p, NULL, &listen_host, &listen_port)
> +                         == -1)
>                               errx(1, "bad listen address: %s", optarg);
>                       break;
>               case 'U':               /* allow udp only from address */
> -                     if (loghost_parse(optarg, NULL, &bind_host, &bind_port)
> +                     if ((p = strdup(optarg)) == NULL)
> +                             err(1, "strdup bind address");
> +                     if (loghost_parse(p, NULL, &bind_host, &bind_port)
>                           == -1)
>                               errx(1, "bad bind address: %s", optarg);
>                       break;

Reply via email to