git: 306d3fb23d7c - main - libpfct: fix incorrect array check

From: Kristof Provost <kp_at_FreeBSD.org>
Date: Fri, 02 Feb 2024 16:55:42 UTC
The branch main has been updated by kp:

URL: https://cgit.FreeBSD.org/src/commit/?id=306d3fb23d7ccbc327b6038df2088629daff87b4

commit 306d3fb23d7ccbc327b6038df2088629daff87b4
Author:     Kristof Provost <kp@FreeBSD.org>
AuthorDate: 2024-02-01 21:32:32 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2024-02-02 16:55:16 +0000

    libpfct: fix incorrect array check
    
    Reported by:    Coverity Scan
    CID:            1523771
    Sponsored by:   Rubicon Communications, LLC ("Netgate")
---
 lib/libpfctl/libpfctl.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/libpfctl/libpfctl.c b/lib/libpfctl/libpfctl.c
index cb9b377f7b6c..71546c4709c2 100644
--- a/lib/libpfctl/libpfctl.c
+++ b/lib/libpfctl/libpfctl.c
@@ -965,8 +965,8 @@ snl_add_msg_attr_rule_labels(struct snl_writer *nw, uint32_t type, const char la
 
 	off = snl_add_msg_attr_nested(nw, type);
 
-	while (labels[i][0] != 0 &&
-	    i < PF_RULE_MAX_LABEL_COUNT) {
+	while (i < PF_RULE_MAX_LABEL_COUNT &&
+	    labels[i][0] != 0) {
 		snl_add_msg_attr_string(nw, PF_LT_LABEL, labels[i]);
 		i++;
 	}