aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2008-02-01 17:23:47 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2008-02-01 17:23:47 +0000
commitbda31f54440215d62b9cca92498ce390262638c8 (patch)
tree7ce70215b75827eba4d04f405a50c9b4ba625e3b /apps
parentfc2b1594a907d8a4c0f109790f1a1054358d6732 (diff)
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/branches/1.4@101818 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps')
-rw-r--r--apps/app_authenticate.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/apps/app_authenticate.c b/apps/app_authenticate.c
index 5985993a8..c7a061829 100644
--- a/apps/app_authenticate.c
+++ b/apps/app_authenticate.c
@@ -169,7 +169,9 @@ static int auth_exec(struct ast_channel *chan, void *data)
while (!feof(f)) {
fgets(buf, sizeof(buf), f);
if (!feof(f) && !ast_strlen_zero(buf)) {
- buf[strlen(buf) - 1] = '\0';
+ size_t len = strlen(buf);
+ if (buf[len] == '\n')
+ buf[len] = '\0';
if (ast_test_flag(&flags,OPT_MULTIPLE)) {
md5secret = strchr(buf, ':');
if (md5secret == NULL)