[Home]

Summary:ASTERISK-23904: #define AST_MAX_ACCOUNT_CODE 20 causes truncation
Reporter:Ben Merrills (skrusty)Labels:
Date Opened:2014-06-18 04:35:38Date Closed:2016-09-23 14:17:28
Priority:MajorRegression?
Status:Closed/CompleteComponents:CDR/General
Versions:12.3.2 Frequency of
Occurrence
Related
Issues:
Environment:Attachments:
Description:When using an account code that is 20 chars long, asterisk truncates the account code to 19 chars too allow for tailing '\0'. AS the DB field is 20, and almost all documentation i can find says the max len of the account code is 20, i suggest upping the flag to 21 to allow for the extra char.

#define AST_MAX_ACCOUNT_CODE   21
Comments:By: Ben Merrills (skrusty) 2014-06-18 05:09:02.723-0500

Note: I have changed the cdr.h on my local copy and tested, this of course does resolve the issue.

By: Ben Merrills (skrusty) 2015-02-03 02:57:38.711-0600

Would it be appropriate to extend the length of this field further, to accommodate UUID/Guid's? Extended the field to 36 chars + null (37) would allow for a UUID/Guid with hyphens to be used as the account code.

For example:
36 characters (Hyphenated)
Example: 12345678-1234-1234-1234-123456789abc

By: Walter Doekes (wdoekes) 2015-02-03 04:32:22.218-0600

Sounds good to me.

Note that sippeers.sql already uses 40 characters as limit:
{noformat}
asterisk-11.x-WRITE$ find . -name '*.sql' | xargs grep accountco
./contrib/realtime/mysql/sippeers.sql:      `accountcode` varchar(40) DEFAULT NULL,
./contrib/realtime/mysql/iaxfriends.sql:  `accountcode` varchar(20) NULL,
./contrib/realtime/postgresql/realtime.sql:accountcode character varying(20) DEFAULT '' NOT NULL,
./contrib/realtime/postgresql/realtime.sql:accountcode character varying(20),
{noformat}

I consider it safe to increase to 41 (40 in the docs) in branch 11 and up.

By: Walter Doekes (wdoekes) 2015-02-04 05:16:43.891-0600

Corey Farrell kindly pointed out the ABI issues involved with increasing AST_MAX_ACCOUNT_CODE:

struct ast_cdr in include/asterisk/cdr.h would get enlarged. So it's best to leave that alone. But we could still:
- increase the size in trunk (to 40? 60? 80?)
- decrease the documented value in all other branches to 19

By: Corey Farrell (coreyfarrell) 2015-02-04 06:28:27.745-0600

For trunk I would like to recommend that we have AST_MAX_ACCOUNT_CODE equal to AST_MAX_EXTENSION (80).  The idea is to allow setting account-code to any $\{EXTEN} without truncating.