From 9fef0798c662808017dce9ecd4c6c7d82e1c0fa3 Mon Sep 17 00:00:00 2001 From: phessler Date: Fri, 17 Apr 2015 07:51:09 +0000 Subject: [PATCH] parse_prefix in parse.c got changed but the declaration in bgpctl.c wasn't updated, so we would crash when doing `bgpctl net bulk` commands. Fix by moving parse_prefix into a header, since we use it in more than one file. crash found by henning@ underlying problem found by blambert@ OK sthen@ deraadt@ claudio@ henning@ --- usr.sbin/bgpctl/bgpctl.c | 7 ++----- usr.sbin/bgpctl/parser.c | 4 +--- usr.sbin/bgpctl/parser.h | 4 +++- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/usr.sbin/bgpctl/bgpctl.c b/usr.sbin/bgpctl/bgpctl.c index d68a3f53be8..65d3c60724e 100644 --- a/usr.sbin/bgpctl/bgpctl.c +++ b/usr.sbin/bgpctl/bgpctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bgpctl.c,v 1.177 2015/02/11 23:47:25 phessler Exp $ */ +/* $OpenBSD: bgpctl.c,v 1.178 2015/04/17 07:51:09 phessler Exp $ */ /* * Copyright (c) 2003 Henning Brauer @@ -96,9 +96,6 @@ void mrt_to_bgpd_addr(union mrt_addr *, struct bgpd_addr *); void network_bulk(struct parse_result *); const char *print_auth_method(enum auth_method); -/* parser.c */ -int parse_prefix(const char *, struct bgpd_addr *, u_int8_t *); - struct imsgbuf *ibuf; struct mrt_parser show_mrt = { show_mrt_dump, show_mrt_state, show_mrt_msg }; struct mrt_parser net_mrt = { network_mrt_dump, NULL, NULL }; @@ -1692,7 +1689,7 @@ network_bulk(struct parse_result *res) if (strchr(b, '#') != NULL) break; bzero(&net, sizeof(net)); - parse_prefix(b, &h, &len); + parse_prefix(b, strlen(b), &h, &len); memcpy(&net.prefix, &h, sizeof(h)); net.prefixlen = len; diff --git a/usr.sbin/bgpctl/parser.c b/usr.sbin/bgpctl/parser.c index bf48e3f591f..aca49369622 100644 --- a/usr.sbin/bgpctl/parser.c +++ b/usr.sbin/bgpctl/parser.c @@ -1,4 +1,4 @@ -/* $OpenBSD: parser.c,v 1.69 2014/11/19 21:11:41 tedu Exp $ */ +/* $OpenBSD: parser.c,v 1.70 2015/04/17 07:51:09 phessler Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -386,8 +386,6 @@ const struct token *match_token(int *argc, char **argv[], const struct token []); void show_valid_args(const struct token []); int parse_addr(const char *, struct bgpd_addr *); -int parse_prefix(const char *, size_t, struct bgpd_addr *, - u_int8_t *); int parse_asnum(const char *, size_t, u_int32_t *); int parse_number(const char *, struct parse_result *, enum token_type); diff --git a/usr.sbin/bgpctl/parser.h b/usr.sbin/bgpctl/parser.h index fd298fda7bc..d0d0ab95a94 100644 --- a/usr.sbin/bgpctl/parser.h +++ b/usr.sbin/bgpctl/parser.h @@ -1,4 +1,4 @@ -/* $OpenBSD: parser.h,v 1.26 2013/10/09 08:56:38 phessler Exp $ */ +/* $OpenBSD: parser.h,v 1.27 2015/04/17 07:51:09 phessler Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -76,3 +76,5 @@ struct parse_result { __dead void usage(void); struct parse_result *parse(int, char *[]); +int parse_prefix(const char *, size_t, struct bgpd_addr *, + u_int8_t *); -- 2.20.1