mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-05 12:16:00 +00:00
Don't truncate database results at 255 chars.
(closes issue #14069) Reported by: evandro Patches: 20081214__bug14069.diff.txt uploaded by Corydon76 (license 14) git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@167840 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -1262,16 +1262,35 @@ static int handle_verbose(struct ast_channel *chan, AGI *agi, int argc, char **a
|
||||
static int handle_dbget(struct ast_channel *chan, AGI *agi, int argc, char **argv)
|
||||
{
|
||||
int res;
|
||||
char tmp[256];
|
||||
size_t bufsize = 16;
|
||||
char *buf, *tmp;
|
||||
|
||||
if (argc != 4)
|
||||
return RESULT_SHOWUSAGE;
|
||||
res = ast_db_get(argv[2], argv[3], tmp, sizeof(tmp));
|
||||
|
||||
if (!(buf = ast_malloc(bufsize))) {
|
||||
fdprintf(agi->fd, "200 result=-1\n");
|
||||
return RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
do {
|
||||
res = ast_db_get(argv[2], argv[3], buf, bufsize);
|
||||
if (strlen(buf) < bufsize - 1) {
|
||||
break;
|
||||
}
|
||||
bufsize *= 2;
|
||||
if (!(tmp = ast_realloc(buf, bufsize))) {
|
||||
break;
|
||||
}
|
||||
buf = tmp;
|
||||
} while (1);
|
||||
|
||||
if (res)
|
||||
fdprintf(agi->fd, "200 result=0\n");
|
||||
else
|
||||
fdprintf(agi->fd, "200 result=1 (%s)\n", tmp);
|
||||
fdprintf(agi->fd, "200 result=1 (%s)\n", buf);
|
||||
|
||||
ast_free(buf);
|
||||
return RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user