]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
config: Fix CB_ADD_LEN() to work as originally intended.
authorRichard Mudgett <rmudgett@digium.com>
Tue, 8 Apr 2014 20:49:11 +0000 (20:49 +0000)
committerRichard Mudgett <rmudgett@digium.com>
Tue, 8 Apr 2014 20:49:11 +0000 (20:49 +0000)
Fix a long standing bug in CB_ADD_LEN() behaving like CB_ADD().

ASTERISK-23546 #close
Reported by: Walter Doekes

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@411960 65c4cc65-6c06-0410-ace0-fbb531ad65f3

main/config.c

index 16603952215dce6dc253e4b1f469f7c50336883a..4a88ef3871d9cab81a96330eb94f3fd79cd3de4a 100644 (file)
@@ -122,8 +122,10 @@ static void  CB_ADD(struct ast_str **cb, const char *str)
 static void  CB_ADD_LEN(struct ast_str **cb, const char *str, int len)
 {
        char *s = ast_alloca(len + 1);
-       ast_copy_string(s, str, len);
-       ast_str_append(cb, 0, "%s", str);
+
+       memcpy(s, str, len);
+       s[len] = '\0';
+       ast_str_append(cb, 0, "%s", s);
 }
 
 static void CB_RESET(struct ast_str *cb, struct ast_str *llb)  
@@ -1648,7 +1650,7 @@ static struct ast_config *config_text_file_load(const char *database, const char
                                        } else if ((comment_p >= new_buf + 2) &&
                                                   (*(comment_p - 1) == COMMENT_TAG) &&
                                                   (*(comment_p - 2) == COMMENT_TAG)) {
-                                               /* Meta-Comment end detected */
+                                               /* Meta-Comment end detected "--;" */
                                                comment--;
                                                new_buf = comment_p + 1;
                                                if (!comment) {