Skip to content

Commit

Permalink
libbsnmptools: avoid uninitialized snmptoolctx->passwd with empty pas…
Browse files Browse the repository at this point in the history
…sword

The removed check left snmptoolctx->passwd pointer to uninitialized
memory.  Always calling strlcpy(3) would guarantee that with empty
password it will point to empty string.

Submitted by:	markj
PR:		283909
  • Loading branch information
glebius committed Jan 11, 2025
1 parent 4dc1820 commit 3999a86
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,7 @@ snmptool_init(struct snmp_toolinfo *snmptoolctx)
warn("malloc() failed");
return (-1);
}
if (slen > 0)
strlcpy(snmptoolctx->passwd, str, slen + 1);
strlcpy(snmptoolctx->passwd, str, slen + 1);
}

return (0);
Expand Down

0 comments on commit 3999a86

Please sign in to comment.