]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Fix ISDN calling subaddr User Specified Odd/Even Flag
authorAlec L Davis <sivad.a@paradise.net.nz>
Thu, 7 Apr 2011 10:19:31 +0000 (10:19 +0000)
committerAlec L Davis <sivad.a@paradise.net.nz>
Thu, 7 Apr 2011 10:19:31 +0000 (10:19 +0000)
Calculation of the Odd/Even flag was wrong.
Implement correct algo, and set odd/even=0 if data would be truncated.
Only allow automatic calculation of the O/E flag, don't let dialplan influence.

(closes issue #19062)
Reported by: festr
Patches:
      bug19062.diff2.txt uploaded by alecdavis (license 585)
Tested by: festr, alecdavis, rmudgett

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@313001 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/sig_pri.c

index 3157436c46c3ea90c1a1018df0fb35463d30e71a..e4d4cdc824368b4720efc70336555eeb86a44018 100644 (file)
@@ -739,8 +739,14 @@ static void sig_pri_party_subaddress_from_ast(struct pri_party_subaddress *pri_s
                        int length = ast_pri_pack_hex_string(pri_subaddress->data,
                                ast_subaddress->str, sizeof(pri_subaddress->data));
 
-                       pri_subaddress->length = length;
-                       pri_subaddress->odd_even_indicator = (length & 1);
+                       pri_subaddress->length = length; /* packed data length */
+
+                       length = strlen(ast_subaddress->str);
+                       if (length > 2 * sizeof(pri_subaddress->data)) {
+                               pri_subaddress->odd_even_indicator = 0;
+                       } else {
+                               pri_subaddress->odd_even_indicator = (length & 1);
+                       }
                        pri_subaddress->valid = 1;
                }
        }
@@ -6415,12 +6421,10 @@ int sig_pri_call(struct sig_pri_chan *p, struct ast_channel *ast, char *rdest, i
                s++;
                /* prefix */
                /* 'n' = NSAP */
-               /* 'U' = odd, 'u'= even */
+               /* 'u' = User Specified */
                /* Default = NSAP */
                switch (*s) {
                case 'U':
-                       dialed_subaddress.odd_even_indicator = 1;
-                       /* fall through */
                case 'u':
                        s++;
                        dialed_subaddress.type = 2;