From f08acd7b45e737b25b9a97182f29861ef07fd1a9 Mon Sep 17 00:00:00 2001
From: Mark Spencer <markster@digium.com>
Date: Fri, 5 Aug 2005 21:44:19 +0000
Subject: [PATCH] Fix newline issue (bug #4632)

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@6291 65c4cc65-6c06-0410-ace0-fbb531ad65f3
---
 apps/app_authenticate.c | 9 +++++++--
 channels/chan_alsa.c    | 1 +
 channels/chan_oss.c     | 1 +
 3 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/apps/app_authenticate.c b/apps/app_authenticate.c
index 887bf237d4..903e7b4115 100755
--- a/apps/app_authenticate.c
+++ b/apps/app_authenticate.c
@@ -125,6 +125,7 @@ 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';
 							if (strchr(opts, 'm')) {
 								md5secret = strchr(buf, ':');
 								if (md5secret == NULL)
@@ -133,12 +134,16 @@ static int auth_exec(struct ast_channel *chan, void *data)
 								md5secret++;
 								ast_md5_hash(md5passwd, passwd);
 								if (!strcmp(md5passwd, md5secret)) {
-									ast_cdr_setaccount(chan, buf);
+									if (strchr(opts, 'a'))
+										ast_cdr_setaccount(chan, buf);
 									break;
 								}
 							} else {
-								if(!strcmp(passwd, buf))
+								if(!strcmp(passwd, buf)) {
+									if (strchr(opts, 'a'))
+										ast_cdr_setaccount(chan, buf);
 									break;
+								}
 							}
 						}
 					}
diff --git a/channels/chan_alsa.c b/channels/chan_alsa.c
index 0fd44922bf..fe82470601 100755
--- a/channels/chan_alsa.c
+++ b/channels/chan_alsa.c
@@ -901,6 +901,7 @@ static int console_sendtext(int fd, int argc, char *argv[])
 			strncat(text2send, argv[tmparg++], sizeof(text2send) - strlen(text2send) - 1);
 			strncat(text2send, " ", sizeof(text2send) - strlen(text2send) - 1);
 		}
+		text2send[strlen(text2send) - 1] = '\n';
 		f.data = text2send;
 		f.datalen = strlen(text2send) + 1;
 		grab_owner();
diff --git a/channels/chan_oss.c b/channels/chan_oss.c
index 4635f78496..92080fe07f 100755
--- a/channels/chan_oss.c
+++ b/channels/chan_oss.c
@@ -1019,6 +1019,7 @@ static int console_sendtext(int fd, int argc, char *argv[])
 			sizeof(text2send) - strlen(text2send) - 1);
 	}
 	if (!ast_strlen_zero(text2send)) {
+		text2send[strlen(text2send) - 1] = '\n';
 		f.frametype = AST_FRAME_TEXT;
 		f.subclass = 0;
 		f.data = text2send;
-- 
GitLab