diff options
author | dfr <dfr@FreeBSD.org> | 2008-05-07 13:39:42 +0000 |
---|---|---|
committer | dfr <dfr@FreeBSD.org> | 2008-05-07 13:39:42 +0000 |
commit | 51b6601db456e699ea5d4843cbc7239ee92d9c13 (patch) | |
tree | 4dbb862199a916e3ffe75f1cb08703ec0e662ffc /crypto/heimdal/kadmin/random_password.c | |
parent | 2565fa13487d5bfc858144e431e3dfd7ffa5200e (diff) | |
download | FreeBSD-src-51b6601db456e699ea5d4843cbc7239ee92d9c13.zip FreeBSD-src-51b6601db456e699ea5d4843cbc7239ee92d9c13.tar.gz |
Vendor import of Heimdal 1.1
Diffstat (limited to 'crypto/heimdal/kadmin/random_password.c')
-rw-r--r-- | crypto/heimdal/kadmin/random_password.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/crypto/heimdal/kadmin/random_password.c b/crypto/heimdal/kadmin/random_password.c index 92fb2fc..d56dd94 100644 --- a/crypto/heimdal/kadmin/random_password.c +++ b/crypto/heimdal/kadmin/random_password.c @@ -33,7 +33,7 @@ #include "kadmin_locl.h" -RCSID("$Id: random_password.c,v 1.4 2001/02/15 04:20:53 assar Exp $"); +RCSID("$Id: random_password.c 21745 2007-07-31 16:11:25Z lha $"); /* This file defines some a function that generates a random password, that can be used when creating a large amount of principals (such @@ -123,7 +123,11 @@ generate_password(char **pw, int num_classes, ...) unsigned char rbuf[8]; /* random buffer */ int rleft = 0; + *pw = NULL; + classes = malloc(num_classes * sizeof(*classes)); + if(classes == NULL) + return; va_start(ap, num_classes); len = 0; for(i = 0; i < num_classes; i++){ @@ -134,8 +138,10 @@ generate_password(char **pw, int num_classes, ...) } va_end(ap); *pw = malloc(len + 1); - if(*pw == NULL) + if(*pw == NULL) { + free(classes); return; + } for(i = 0; i < len; i++) { int j; int x = RND(rbuf, sizeof(rbuf), &rleft) % (len - i); |