From b840faef38192fa76a691b2f27ee9b13dde56d0e Mon Sep 17 00:00:00 2001 From: florian Date: Wed, 21 Aug 2024 09:17:05 +0000 Subject: [PATCH] Use inet_pton to parse ext-communities with an IPv4 address. No need for inet_aton's flexibility. OK claudio --- usr.sbin/bgpctl/parser.c | 4 ++-- usr.sbin/bgpd/parse.y | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/usr.sbin/bgpctl/parser.c b/usr.sbin/bgpctl/parser.c index 7654051b8b1..ee86917744d 100644 --- a/usr.sbin/bgpctl/parser.c +++ b/usr.sbin/bgpctl/parser.c @@ -1,4 +1,4 @@ -/* $OpenBSD: parser.c,v 1.135 2024/08/14 19:10:51 claudio Exp $ */ +/* $OpenBSD: parser.c,v 1.136 2024/08/21 09:17:05 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_aton(s, &ip) == 0) + if (inet_pton(AF_INET, s, &ip) == 0) 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 1621c8a1dff..d8841db3698 100644 --- a/usr.sbin/bgpd/parse.y +++ b/usr.sbin/bgpd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.465 2024/08/14 19:09:51 claudio Exp $ */ +/* $OpenBSD: parse.y,v 1.466 2024/08/21 09:17:05 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_aton(s, &ip) == 0) { + if (inet_pton(AF_INET, s, &ip) == 0) { yyerror("Bad ext-community %s not parseable", s); return (-1); } -- 2.20.1