diff options
author | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-02-01 17:26:31 +0000 |
---|---|---|
committer | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-02-01 17:26:31 +0000 |
commit | 555b2bd3c96e1ad756bc4d1a723f05b08a591cb5 (patch) | |
tree | 6ca286a57ff25359a25d969d9cf452975c41ff1a | |
parent | b2033ac5cf99119725b9d7443d7223fe9c6f81af (diff) |
Merged revisions 101818 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r101818 | russell | 2008-02-01 11:23:47 -0600 (Fri, 01 Feb 2008) | 4 lines
Don't overwrite the last character of a line if it's not a newline. This would
happen if the last line in the file doesn't have a newline.
(pointed out by Qwell)
........
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@101819 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r-- | apps/app_authenticate.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/apps/app_authenticate.c b/apps/app_authenticate.c index 30ddc4127..408de55f8 100644 --- a/apps/app_authenticate.c +++ b/apps/app_authenticate.c @@ -148,6 +148,8 @@ static int auth_exec(struct ast_channel *chan, void *data) } for (;;) { + size_t len; + fgets(buf, sizeof(buf), f); if (feof(f)) @@ -156,7 +158,9 @@ static int auth_exec(struct ast_channel *chan, void *data) if (ast_strlen_zero(buf)) continue; - buf[strlen(buf) - 1] = '\0'; + len = strlen(buf) - 1; + if (buf[len - 1] = '\n') + buf[len - 1] = '\0'; if (ast_test_flag(&flags, OPT_MULTIPLE)) { md5secret = buf; |