From: Russell Bryant Date: Fri, 1 Feb 2008 17:26:31 +0000 (+0000) Subject: Merged revisions 101818 via svnmerge from X-Git-Tag: 1.6.0-beta3~2^2~105 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=99c36129a58e63cc910255548938f2b903184f4f;p=thirdparty%2Fasterisk.git 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: https://origsvn.digium.com/svn/asterisk/trunk@101819 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/apps/app_authenticate.c b/apps/app_authenticate.c index 30ddc41279..408de55f88 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;