From a011bc90ddf52787b7dca3cc3caf01fe3b1a88c1 Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Wed, 10 May 2017 16:06:22 +0000 Subject: Don't depend on assert(3) getting evaluated Reported by: imp MFC after: 3 weeks X-MFC-With: 318141, 318143 Sponsored by: Spectra Logic Corp --- pw/pw_user.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'pw') diff --git a/pw/pw_user.c b/pw/pw_user.c index cf38e9c..76849ba 100644 --- a/pw/pw_user.c +++ b/pw/pw_user.c @@ -491,6 +491,7 @@ pw_pwcrypt(char *password) char salt[SALTSIZE + 1]; char *cryptpw; static char buf[256]; + size_t pwlen; /* * Calculate a salt value @@ -502,7 +503,8 @@ pw_pwcrypt(char *password) cryptpw = crypt(password, salt); if (cryptpw == NULL) errx(EX_CONFIG, "crypt(3) failure"); - assert(strlcpy(buf, cryptpw, sizeof(buf)) < sizeof(buf)); + pwlen = strlcpy(buf, cryptpw, sizeof(buf)); + assert(pwlen < sizeof(buf)); return (buf); } -- cgit v1.2.3-56-ge451