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
This commit is contained in:
Alan Somers 2017-05-10 16:06:22 +00:00
parent daccabe958
commit 0ce59aa848
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=318144
2 changed files with 6 additions and 4 deletions

View file

@ -108,7 +108,7 @@ int main(int argc, char **argv)
struct mkuz_conveyor *cvp;
void *c_ctx;
struct mkuz_blk_info *chit;
size_t ncpusz, ncpu;
size_t ncpusz, ncpu, magiclen;
double st, et;
st = getdtime();
@ -192,8 +192,8 @@ int main(int argc, char **argv)
/* Not reached */
}
assert(strlcpy(hdr.magic, cfs.handler->magic, sizeof(hdr.magic))
< sizeof(hdr.magic));
magiclen = strlcpy(hdr.magic, cfs.handler->magic, sizeof(hdr.magic));
assert(magiclen < sizeof(hdr.magic));
if (cfs.en_dedup != 0) {
hdr.magic[CLOOP_OFS_VERSN] = CLOOP_MAJVER_3;

View file

@ -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);
}