From: Russell Bryant Date: Fri, 1 Feb 2008 17:23:47 +0000 (+0000) Subject: Don't overwrite the last character of a line if it's not a newline. This would X-Git-Tag: 1.4.19~216 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=552f2e1b4c245e7648c3fe89ce549057776ca6d7;p=thirdparty%2Fasterisk.git 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/branches/1.4@101818 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/apps/app_authenticate.c b/apps/app_authenticate.c index 5985993a81..c7a0618290 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)