summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorCorey Farrell <git@cfware.com>2018-02-23 11:09:46 -0500
committerCorey Farrell <git@cfware.com>2018-02-23 12:12:04 -0500
commita7927471adc67daa7b335811ee640774904d5d3a (patch)
tree8cab723606549c7b60d6243bed3b39add3e19345 /main
parentd6d520a0406f7097346edf02a5bc6749779aafd6 (diff)
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
Diffstat (limited to 'main')
-rw-r--r--main/config.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/main/config.c b/main/config.c
index 118b9586e..8107fce04 100644
--- a/main/config.c
+++ b/main/config.c
@@ -2195,10 +2195,10 @@ static struct ast_config *config_text_file_load(const char *database, const char
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;
}
}