summaryrefslogtreecommitdiffstats
path: root/support/htpasswd.c
diff options
context:
space:
mode:
authorYann Ylavic <ylavic@apache.org>2017-02-03 09:51:49 +0100
committerYann Ylavic <ylavic@apache.org>2017-02-03 09:51:49 +0100
commitce23a724d7b574acd0d2a024cd6d212cd8304cc4 (patch)
treecf001f251a1e6956a41d84260cd5b7e93412dee9 /support/htpasswd.c
parentadd name (diff)
downloadapache2-ce23a724d7b574acd0d2a024cd6d212cd8304cc4.tar.xz
apache2-ce23a724d7b574acd0d2a024cd6d212cd8304cc4.zip
htpasswd: don't point to (unused) stack memory on output
to make static analysers happy. PR 60634. Reported by shqking and Zhenwei Zou. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1781509 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'support/htpasswd.c')
-rw-r--r--support/htpasswd.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/support/htpasswd.c b/support/htpasswd.c
index 11023499a4..e627f8b9bf 100644
--- a/support/htpasswd.c
+++ b/support/htpasswd.c
@@ -75,15 +75,20 @@ static int mkrecord(struct passwd_ctx *ctx, char *user)
{
char hash_str[MAX_STRING_LEN];
int ret;
+
ctx->out = hash_str;
ctx->out_len = sizeof(hash_str);
ret = mkhash(ctx);
- if (ret)
+ if (ret) {
+ ctx->out = NULL;
+ ctx->out_len = 0;
return ret;
+ }
ctx->out = apr_pstrcat(ctx->pool, user, ":", hash_str, NL, NULL);
- if (strlen(ctx->out) >= MAX_STRING_LEN) {
+ ctx->out_len = strlen(ctx->out);
+ if (ctx->out_len >= MAX_STRING_LEN) {
ctx->errstr = "resultant record too long";
return ERR_OVERFLOW;
}