[Asterisk-code-review] core: Fix handling of maximum length lines in config files. (asterisk[15])
Jenkins2
asteriskteam at digium.com
Mon Mar 5 08:17:52 CST 2018
Jenkins2 has submitted this change and it was merged. ( https://gerrit.asterisk.org/8381 )
Change subject: core: Fix handling of maximum length lines in config files.
......................................................................
core: Fix handling of maximum length lines in config files.
When a line is the maximum length "\n" is found at sizeof(buf) - 2 since
the last character is actually the null terminator. In addition if a
line was exactly 8190 plus a multiple of 8192 characters long the config
parser would skip the following line.
Additionally fix comment in voicemail.conf sample config. It previously
stated that emailbody can only contain up to 512 characters which is
always wrong. The buffer is normally 8192 characters unless LOW_MEMORY
is enabled then it is 512 characters. The updated comment states that
the line can be up to 8190 or 510 characters since the line feed and
NULL terminator each use a character.
ASTERISK-26688 #close
Change-Id: I80864a0d40d2e2d8cd79d72af52a8f0a3a99c015
---
M configs/samples/voicemail.conf.sample
M main/config.c
2 files changed, 5 insertions(+), 4 deletions(-)
Approvals:
Sean Bright: Looks good to me, but someone else must approve
Joshua Colp: Looks good to me, approved
Jenkins2: Approved for Submit
diff --git a/configs/samples/voicemail.conf.sample b/configs/samples/voicemail.conf.sample
index c90f851..e4130d3 100644
--- a/configs/samples/voicemail.conf.sample
+++ b/configs/samples/voicemail.conf.sample
@@ -145,8 +145,9 @@
; You can select between two variables by using dialplan functions, e.g.
; ${IF(${ISNULL(${ORIG_VM_DATE})}?${VM_DATE}:${ORIG_VM_DATE})}
;
-; Note: The emailbody config row can only be up to 512 characters due to a
-; limitation in the Asterisk configuration subsystem.
+; Note: The emailbody config row can only be up to 8190 characters due to a
+; limitation in the Asterisk configuration subsystem. If compiled with
+; LOW_MEMORY the limit is 510 characters.
;emailsubject=[PBX]: New message ${VM_MSGNUM} in mailbox ${VM_MAILBOX}
; The following definition is very close to the default, but the default shows
; just the CIDNAME, if it is not null, otherwise just the CIDNUM, or "an unknown
diff --git a/main/config.c b/main/config.c
index 118b958..8107fce 100644
--- a/main/config.c
+++ b/main/config.c
@@ -2195,10 +2195,10 @@
lineno++;
if (fgets(buf, sizeof(buf), f)) {
/* Skip lines that are too long */
- if (strlen(buf) == sizeof(buf) - 1 && buf[sizeof(buf) - 1] != '\n') {
+ if (strlen(buf) == sizeof(buf) - 1 && buf[sizeof(buf) - 2] != '\n') {
ast_log(LOG_WARNING, "Line %d too long, skipping. It begins with: %.32s...\n", lineno, buf);
while (fgets(buf, sizeof(buf), f)) {
- if (strlen(buf) != sizeof(buf) - 1 || buf[sizeof(buf) - 1] == '\n') {
+ if (strlen(buf) != sizeof(buf) - 1 || buf[sizeof(buf) - 2] == '\n') {
break;
}
}
--
To view, visit https://gerrit.asterisk.org/8381
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: 15
Gerrit-MessageType: merged
Gerrit-Change-Id: I80864a0d40d2e2d8cd79d72af52a8f0a3a99c015
Gerrit-Change-Number: 8381
Gerrit-PatchSet: 2
Gerrit-Owner: Corey Farrell <git at cfware.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Sean Bright <sean.bright at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180305/12f2d5d4/attachment.html>
More information about the asterisk-code-review
mailing list