git: 8ed2e663712c - stable/13 - libbsnmp: avoid division by zero with empty password

From: Ed Maste <emaste_at_FreeBSD.org>
Date: Mon, 20 Jan 2025 14:29:10 UTC
The branch stable/13 has been updated by emaste:

URL: https://cgit.FreeBSD.org/src/commit/?id=8ed2e663712c3749b10af7968a646b9e81b6bcea

commit 8ed2e663712c3749b10af7968a646b9e81b6bcea
Author:     Gleb Smirnoff <glebius@FreeBSD.org>
AuthorDate: 2025-01-11 05:08:02 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2025-01-20 14:28:54 +0000

    libbsnmp: avoid division by zero with empty password
    
    PR:             283909
    (cherry picked from commit 4dc1820a16b9b6108e0ff8a0265c08c67fa34146)
    (cherry picked from commit c4cae8cbc337eaf824774fcba88018e42fa31efa)
---
 contrib/bsnmp/lib/snmpclient.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/contrib/bsnmp/lib/snmpclient.c b/contrib/bsnmp/lib/snmpclient.c
index 05711e341fd7..a7556527ad51 100644
--- a/contrib/bsnmp/lib/snmpclient.c
+++ b/contrib/bsnmp/lib/snmpclient.c
@@ -1792,7 +1792,7 @@ snmp_discover_engine(char *passwd)
 	if (snmp_client.user.auth_proto == SNMP_AUTH_NOAUTH)
 		return (0);
 
-	if (passwd == NULL ||
+	if (passwd == NULL || strlen(passwd) == 0 ||
 	    snmp_passwd_to_keys(&snmp_client.user, passwd) != SNMP_CODE_OK ||
 	    snmp_get_local_keys(&snmp_client.user, snmp_client.engine.engine_id,
 	    snmp_client.engine.engine_len) != SNMP_CODE_OK)