lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <87sfkjcfrj.fsf@mail.parknet.co.jp>
Date:   Fri, 23 Sep 2022 05:31:44 +0900
From:   OGAWA Hirofumi <hirofumi@...l.parknet.co.jp>
To:     Stephen Hemminger <stephen@...workplumber.org>
Cc:     netdev@...r.kernel.org
Subject: Re: [PATCH iproute2] Fix segv on "-r" option if unknown rpc service

Stephen Hemminger <stephen@...workplumber.org> writes:

> On Sun, 18 Sep 2022 02:50:54 +0900
> OGAWA Hirofumi <hirofumi@...l.parknet.co.jp> wrote:
>
>> +		} else {
>> +			const char fmt[] = "%s%u";
>> +			char *buf = NULL;
>> +			int len = snprintf(buf, 0, fmt, prog,
>> +					   rhead->rpcb_map.r_prog);
>> +			len++;
>> +			buf = malloc(len);
>> +			snprintf(buf, len, fmt, prog, rhead->rpcb_map.r_prog);
>> +			c->name = buf;
>>  		}
>
> Thanks for finding the bug but this could be improved.
> This seems like the hard way to do this.
> You are reinventing asprintf().

Right, if this project is assuming the extension is available.

> Would this work instead.

Thanks.

> diff --git a/misc/ss.c b/misc/ss.c
> index ff985cd8cae9..9d3d0bd84df3 100644
> --- a/misc/ss.c
> +++ b/misc/ss.c
> @@ -1596,6 +1596,10 @@ static void init_service_resolver(void)
>                 if (rpc) {
>                         strncat(prog, rpc->r_name, 128 - strlen(prog));
>                         c->name = strdup(prog);
> +               } else if (asprintf(&c->name, "%s%u",
> +                                   prog, rhead->rpcb_map.r_prog) < 0) {
> +                       fprintf(stderr, "ss: asprintf failed to allocate buffer\n");
> +                       abort();
>                 }
>  
>                 c->next = rlist;

-- 
OGAWA Hirofumi <hirofumi@...l.parknet.co.jp>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ