This adjusts the bgpd code (which was copied to bgpctl) to be like the version in bgpctl (after input from tb@).
-- :wq Claudio Index: parse.y =================================================================== RCS file: /cvs/src/usr.sbin/bgpd/parse.y,v retrieving revision 1.449 diff -u -p -r1.449 parse.y --- parse.y 19 Apr 2023 15:27:46 -0000 1.449 +++ parse.y 20 Apr 2023 20:51:23 -0000 @@ -5579,7 +5579,7 @@ static void component_finish(int type, uint8_t *data, int len) { uint8_t *last; - int i = 0; + int i; switch (type) { case FLOWSPEC_TYPE_DEST: @@ -5590,6 +5590,7 @@ component_finish(int type, uint8_t *data break; } + i= 0; do { last = data + i; i += FLOWSPEC_OP_LEN(*last) + 1; @@ -5652,7 +5653,7 @@ push_prefix(struct bgpd_addr *addr, uint { void *data; uint8_t *comp; - int complen, l = 0; + int complen, l; if (curflow->components[curflow->addr_type] != NULL) { yyerror("flowspec address already set"); @@ -5681,10 +5682,11 @@ push_prefix(struct bgpd_addr *addr, uint return -1; } + l = 0; comp[l++] = len; if (curflow->aid == AID_INET6) comp[l++] = 0; - memcpy(comp + l, data, PREFIX_SIZE(len) - 1); + memcpy(comp + l, data, complen - l); curflow->complen[curflow->addr_type] = complen; curflow->components[curflow->addr_type] = comp;