pw_user.c (daccabe958923500d73bfa6d9d732ca9728b4276) | pw_user.c (0ce59aa848470e6e5060b9c2b47fce7888546547) |
---|---|
1/*- 2 * Copyright (C) 1996 3 * David L. Nugent. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 477 unchanged lines hidden (view full) --- 486 487char * 488pw_pwcrypt(char *password) 489{ 490 int i; 491 char salt[SALTSIZE + 1]; 492 char *cryptpw; 493 static char buf[256]; | 1/*- 2 * Copyright (C) 1996 3 * David L. Nugent. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 477 unchanged lines hidden (view full) --- 486 487char * 488pw_pwcrypt(char *password) 489{ 490 int i; 491 char salt[SALTSIZE + 1]; 492 char *cryptpw; 493 static char buf[256]; |
494 size_t pwlen; |
|
494 495 /* 496 * Calculate a salt value 497 */ 498 for (i = 0; i < SALTSIZE; i++) 499 salt[i] = chars[arc4random_uniform(sizeof(chars) - 1)]; 500 salt[SALTSIZE] = '\0'; 501 502 cryptpw = crypt(password, salt); 503 if (cryptpw == NULL) 504 errx(EX_CONFIG, "crypt(3) failure"); | 495 496 /* 497 * Calculate a salt value 498 */ 499 for (i = 0; i < SALTSIZE; i++) 500 salt[i] = chars[arc4random_uniform(sizeof(chars) - 1)]; 501 salt[SALTSIZE] = '\0'; 502 503 cryptpw = crypt(password, salt); 504 if (cryptpw == NULL) 505 errx(EX_CONFIG, "crypt(3) failure"); |
505 assert(strlcpy(buf, cryptpw, sizeof(buf)) < sizeof(buf)); | 506 pwlen = strlcpy(buf, cryptpw, sizeof(buf)); 507 assert(pwlen < sizeof(buf)); |
506 return (buf); 507} 508 509static char * 510pw_password(struct userconf * cnf, char const * user, bool dryrun) 511{ 512 int i, l; 513 char pwbuf[32]; --- 1303 unchanged lines hidden --- | 508 return (buf); 509} 510 511static char * 512pw_password(struct userconf * cnf, char const * user, bool dryrun) 513{ 514 int i, l; 515 char pwbuf[32]; --- 1303 unchanged lines hidden --- |