mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-21 09:10:36 +00:00
add more paranoid handling to pbx_builtin_serialize_variables
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@4107 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
13
pbx.c
13
pbx.c
@@ -4921,18 +4921,21 @@ int pbx_builtin_serialize_variables(struct ast_channel *chan, char *buf, size_t
|
|||||||
{
|
{
|
||||||
struct ast_var_t *variables;
|
struct ast_var_t *variables;
|
||||||
struct varshead *headp;
|
struct varshead *headp;
|
||||||
|
char *var=NULL ,*val=NULL;
|
||||||
int total = 0;
|
int total = 0;
|
||||||
|
|
||||||
memset(buf,0,size);
|
memset(buf,0,size);
|
||||||
if (chan) {
|
if (chan) {
|
||||||
headp=&chan->varshead;
|
headp=&chan->varshead;
|
||||||
AST_LIST_TRAVERSE(headp,variables,entries) {
|
AST_LIST_TRAVERSE(headp,variables,entries) {
|
||||||
snprintf(buf + strlen(buf), size - strlen(buf), "%s=%s\n", ast_var_name(variables), ast_var_value(variables));
|
if(chan && variables && (var=ast_var_name(variables)) && (val=ast_var_value(variables))) {
|
||||||
if(strlen(buf) >= size) {
|
snprintf(buf + strlen(buf), size - strlen(buf), "%s=%s\n", var, val);
|
||||||
ast_log(LOG_ERROR,"Data Buffer Size Exceeded!\n");
|
if(strlen(buf) >= size) {
|
||||||
break;
|
ast_log(LOG_ERROR,"Data Buffer Size Exceeded!\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
total++;
|
||||||
}
|
}
|
||||||
total++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user