From f885c9d92adf97ebff462545fd95c5f3a239cc1d Mon Sep 17 00:00:00 2001 From: florian Date: Thu, 22 Aug 2024 08:17:54 +0000 Subject: [PATCH] inet_pton returns 0 and -1 for error. Adjust the error check that is now wrong after the inet_aton -> inet_pton conversion. Noticed by & OK bluhm. OK tb --- usr.sbin/bgpctl/parser.c | 4 ++-- usr.sbin/bgpd/parse.y | 4 ++-- usr.sbin/eigrpd/parse.y | 4 ++-- usr.sbin/ldpd/parse.y | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/usr.sbin/bgpctl/parser.c b/usr.sbin/bgpctl/parser.c index ee86917744d..e35a952b46d 100644 --- a/usr.sbin/bgpctl/parser.c +++ b/usr.sbin/bgpctl/parser.c @@ -1,4 +1,4 @@ -/* $OpenBSD: parser.c,v 1.136 2024/08/21 09:17:05 florian Exp $ */ +/* $OpenBSD: parser.c,v 1.137 2024/08/22 08:17:54 florian Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -1325,7 +1325,7 @@ parseextvalue(int type, char *s, uint32_t *v, uint32_t *flag) *v = uval | (uvalh << 16); break; case EXT_COMMUNITY_TRANS_IPV4: - if (inet_pton(AF_INET, s, &ip) == 0) + if (inet_pton(AF_INET, s, &ip) != 1) errx(1, "Bad ext-community %s not parseable", s); *v = ntohl(ip.s_addr); break; diff --git a/usr.sbin/bgpd/parse.y b/usr.sbin/bgpd/parse.y index d8841db3698..29af28a313a 100644 --- a/usr.sbin/bgpd/parse.y +++ b/usr.sbin/bgpd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.466 2024/08/21 09:17:05 florian Exp $ */ +/* $OpenBSD: parse.y,v 1.467 2024/08/22 08:17:54 florian Exp $ */ /* * Copyright (c) 2002, 2003, 2004 Henning Brauer @@ -4503,7 +4503,7 @@ parseextvalue(int type, char *s, uint32_t *v, uint32_t *flag) *v = uval | (uvalh << 16); break; case EXT_COMMUNITY_TRANS_IPV4: - if (inet_pton(AF_INET, s, &ip) == 0) { + if (inet_pton(AF_INET, s, &ip) != 1) { yyerror("Bad ext-community %s not parseable", s); return (-1); } diff --git a/usr.sbin/eigrpd/parse.y b/usr.sbin/eigrpd/parse.y index 76118b4072a..56487cdee38 100644 --- a/usr.sbin/eigrpd/parse.y +++ b/usr.sbin/eigrpd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.33 2024/08/21 09:20:36 florian Exp $ */ +/* $OpenBSD: parse.y,v 1.34 2024/08/22 08:17:54 florian Exp $ */ /* * Copyright (c) 2015 Renato Westphal @@ -223,7 +223,7 @@ varset : STRING '=' string { ; conf_main : ROUTERID STRING { - if (!inet_pton(AF_INET, $2, &conf->rtr_id)) { + if (inet_pton(AF_INET, $2, &conf->rtr_id) != 1) { yyerror("error parsing router-id"); free($2); YYERROR; diff --git a/usr.sbin/ldpd/parse.y b/usr.sbin/ldpd/parse.y index d35621cc1e0..2c5f4cf49d2 100644 --- a/usr.sbin/ldpd/parse.y +++ b/usr.sbin/ldpd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.73 2024/08/21 09:17:56 florian Exp $ */ +/* $OpenBSD: parse.y,v 1.74 2024/08/22 08:17:54 florian Exp $ */ /* * Copyright (c) 2013, 2015, 2016 Renato Westphal @@ -203,7 +203,7 @@ string : string STRING { ; routerid : STRING { - if (!inet_pton(AF_INET, $1, &$$)) { + if (inet_pton(AF_INET, $1, &$$) != 1) { yyerror("%s: error parsing router id", $1); free($1); YYERROR; -- 2.20.1