Skip to content

Commit acb72a9

Browse files
committed
res_phreaknet: Increase size of CNAM encoding buffer.
Long CNAMs would fail to encode with the current buffer size, increase to accomodate even the longest reasonable CNAMs. Additionally, add a warning for when this happens.
1 parent 06b4c06 commit acb72a9

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

res/res_phreaknet.c

+6-5
Original file line numberDiff line numberDiff line change
@@ -1734,7 +1734,7 @@ static struct ast_str *phreaknet_lookup_full(const char *number, const char *fla
17341734
{
17351735
static const char *version = NULL;
17361736
static const char *version_num = NULL;
1737-
char url[256];
1737+
char url[319]; /* min to make gcc happy */
17381738

17391739
/* Fetch the first time only */
17401740
if (!version) {
@@ -1776,7 +1776,7 @@ static struct ast_str *phreaknet_lookup(struct ast_channel *chan, const char *nu
17761776
{
17771777
char *clid, *cnam;
17781778
char cvs[3];
1779-
char filtered_cnam[32] = "";
1779+
char filtered_cnam[128] = "";
17801780
int ani2;
17811781
const char *clidverif;
17821782

@@ -1790,6 +1790,7 @@ static struct ast_str *phreaknet_lookup(struct ast_channel *chan, const char *nu
17901790
ast_channel_unlock(chan);
17911791

17921792
if (!ast_strlen_zero(cnam) && safe_encoded_string(cnam, filtered_cnam, sizeof(filtered_cnam))) {
1793+
ast_log(LOG_ERROR, "Failed to encode CNAM string '%s'\n", cnam);
17931794
return NULL;
17941795
}
17951796

@@ -2007,8 +2008,8 @@ static int call_failed(struct ast_channel *chan)
20072008
ast_channel_lock(chan);
20082009
/* These *should* always exist... */
20092010
varval = pbx_builtin_getvar_helper(chan, "DIALSTATUS");
2010-
varval2 = pbx_builtin_getvar_helper(chan, "HANGUPCAUSE");
2011-
ast_debug(3, "Dial disposition: %s (%s)\n", varval, varval2);
2011+
varval2 = pbx_builtin_getvar_helper(chan, "HANGUPCAUSE"); /* Not always set */
2012+
ast_debug(3, "Dial disposition: %s (%s)\n", varval, S_OR(varval2, ""));
20122013
if (varval) {
20132014
if (!strcmp(varval, "CONGESTION") || !strcmp(varval, "CHANUNAVAIL")) {
20142015
ast_channel_unlock(chan);
@@ -2068,7 +2069,7 @@ static int dial_exec(struct ast_channel *chan, const char *data)
20682069
ast_set_flag(&authflags, OPT_AUTH_RSA);
20692070
}
20702071
if (lookup_number_token(chan, args.number, args.trunkflags, lookup, sizeof(lookup), dialopts, sizeof(dialopts))) {
2071-
ast_log(LOG_WARNING, "Lookup failed for %s\n", S_OR(args.number, ""));
2072+
ast_log(LOG_ERROR, "Lookup failed for %s\n", S_OR(args.number, ""));
20722073
pbx_builtin_setvar_helper(chan, "DIALSTATUS", "CHANUNAVAIL");
20732074
return 0;
20742075
}

0 commit comments

Comments
 (0)