summaryrefslogtreecommitdiff
path: root/regress
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2023-01-12 08:47:08 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2023-01-12 08:47:08 +0000
commite248276cd144af45771fefd9ba33a0830e24845b (patch)
tree699a5bdc16c54f36fe77d89e77d2fbd0eb190677 /regress
parent55133ada671a032d447229d88ce80f1bf1d7ce41 (diff)
In build_aspath() be more careful in the len == 0 case. For len == 0
aspath->data should not be touched so just exit early. While there also initalize source_as correctly in the rev case. This does not matter here but is more correct. Problem noticed by anton@ OK tb@
Diffstat (limited to 'regress')
-rw-r--r--regress/usr.sbin/bgpd/unittests/rde_aspa_test.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/regress/usr.sbin/bgpd/unittests/rde_aspa_test.c b/regress/usr.sbin/bgpd/unittests/rde_aspa_test.c
index e1e067dc429..ca75c570508 100644
--- a/regress/usr.sbin/bgpd/unittests/rde_aspa_test.c
+++ b/regress/usr.sbin/bgpd/unittests/rde_aspa_test.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rde_aspa_test.c,v 1.1 2023/01/11 13:55:08 claudio Exp $ */
+/* $OpenBSD: rde_aspa_test.c,v 1.2 2023/01/12 08:47:07 claudio Exp $ */
/*
* Copyright (c) 2022 Claudio Jeker <claudio@openbsd.org>
@@ -615,8 +615,15 @@ build_aspath(const uint32_t *asns, uint32_t asncnt, int rev)
aspath->len = len;
aspath->ascnt = asncnt; /* lie but nothing cares */
aspath->source_as = 0;
- if (len != 0)
+
+ if (len == 0)
+ return aspath;
+
+ if (rev)
+ aspath->source_as = asns[asncnt - 1];
+ else
aspath->source_as = asns[0];
+
aspath->data[0] = AS_SEQUENCE;
aspath->data[1] = asncnt;
for (i = 0; i < asncnt; i++) {