Index | Thread | Search

From:
Florian Obser <florian@openbsd.org>
Subject:
Re: ldpd: get rid of inet_aton
To:
tech@openbsd.org, Alexander Bluhm <bluhm@openbsd.org>, tech <tech@openbsd.org>
Date:
Wed, 21 Aug 2024 22:11:43 +0200

Download raw body.

Thread
Ugh, yes. I've already committed all of these except for radius/npppd.

inet_pton(1) returns 0 or -1 in case of error while inet_aton only returns 0 on error, so ! or == is not correct for error checking.

I'll double check the ones I committed today if there are more mistakes like this.

On August 21, 2024 10:04:01 PM GMT+02:00, Alexander Bluhm <bluhm@openbsd.org> wrote:
>On Wed, Aug 21, 2024 at 09:59:49PM +0200, Alexander Bluhm wrote:
>> On Wed, Aug 21, 2024 at 10:43:11AM +0200, Florian Obser wrote:
>> > OK?
>> 
>> OK bluhm@
>
>Ah, wait.  Should this be if(inet_pton() != 1) ?
>
>> > diff --git parse.y parse.y
>> > index 91606fb6c10..e3c15d41508 100644
>> > --- parse.y
>> > +++ parse.y
>> > @@ -203,7 +203,7 @@ string		: string STRING	{
>> >  		;
>> >
>> >  routerid	: STRING {
>> > -			if (!inet_aton($1, &$$)) {
>> > +			if (!inet_pton(AF_INET, $1, &$$)) {
>> >  				yyerror("%s: error parsing router id", $1);
>> >  				free($1);
>> >  				YYERROR;
>> >
>> > --
>> > In my defence, I have been left unsupervised.
>

-- 
Sent from a mobile device. Please excuse poor formatting.