extensions/mkpasswd: Do not leak /dev/random fd.

This commit is contained in:
Jilles Tjoelker 2014-02-23 22:18:44 +01:00
parent 899b05d387
commit f9960c0262

View file

@ -210,6 +210,7 @@ generate_random_salt(char *salt, int length)
if(read(fd, buf, length) != length) if(read(fd, buf, length) != length)
{ {
free(buf); free(buf);
close(fd);
return (generate_poor_salt(salt, length)); return (generate_poor_salt(salt, length));
} }
@ -218,5 +219,6 @@ generate_random_salt(char *salt, int length)
salt[i] = saltChars[abs(buf[i]) % 64]; salt[i] = saltChars[abs(buf[i]) % 64];
} }
free(buf); free(buf);
close(fd);
return (salt); return (salt);
} }