aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2009-01-08 22:08:56 +0000
committertilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2009-01-08 22:08:56 +0000
commitffd9acbf2a7bc7d28bddd32bb497634b9ec8a751 (patch)
tree9a0309237cda1a7cf074183d5bd78ebcaed95fd5
parentf119c8636f8271102ae820896801aed164bc8d66 (diff)
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: http://svn.digium.com/svn/asterisk/branches/1.4@167840 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r--res/res_agi.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/res/res_agi.c b/res/res_agi.c
index 40c15da82..ae19c4bf4 100644
--- a/res/res_agi.c
+++ b/res/res_agi.c
@@ -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;
}