summaryrefslogtreecommitdiffstats
path: root/support/htpasswd.c
diff options
context:
space:
mode:
Diffstat (limited to 'support/htpasswd.c')
-rw-r--r--support/htpasswd.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/support/htpasswd.c b/support/htpasswd.c
index f67076fffc..16e55a0630 100644
--- a/support/htpasswd.c
+++ b/support/htpasswd.c
@@ -174,6 +174,9 @@ static int mkrecord(char *user, char *record, apr_size_t rlen, char *passwd,
char pwv[MAX_STRING_LEN];
char salt[9];
apr_size_t bufsize;
+#if CRYPT_ALGO_SUPPORTED
+ char *cbuf;
+#endif
if (passwd != NULL) {
pw = passwd;
@@ -226,7 +229,16 @@ static int mkrecord(char *user, char *record, apr_size_t rlen, char *passwd,
to64(&salt[0], rand(), 8);
salt[8] = '\0';
- apr_cpystrn(cpw, crypt(pw, salt), sizeof(cpw) - 1);
+ cbuf = crypt(pw, salt);
+ if (cbuf == NULL) {
+ char errbuf[128];
+
+ apr_snprintf(record, rlen-1, "crypt() failed: %s",
+ apr_strerror(errno, errbuf, sizeof errbuf));
+ return ERR_PWMISMATCH;
+ }
+
+ apr_cpystrn(cpw, cbuf, sizeof(cpw) - 1);
if (strlen(pw) > 8) {
char *truncpw = strdup(pw);
truncpw[8] = '\0';