Summary:ASTERISK-04299: one bug and two useless blocks of code in chan_iax2.c
Reporter:Luigi Rizzo (rizzo)Labels:
Date Opened:2005-05-29 14:44:00Date Closed:2008-01-15 15:36:22.000-0600
Versions:Frequency of
Environment:Attachments:( 0) 4407.stable.patch.txt
Description:1) iax2_show_cache() has the following code segment

    if (!ast_strlen_zero(tmp))
        tmp[strlen(tmp) - 1] = '\0';
        ast_copy_string(tmp, "(none)", sizeof(tmp));

  the first part is a NOP (if strlen succeeds it's because we have a \0
  precisely where we overwrite it), so this could be changed to

    if (ast_strlen_zero(tmp))
         ast_copy_string(tmp, "(none)", sizeof(tmp));

  (which btw is a basic construct used a million times which would deserve
  some form of macro as the one i reported in ASTERISK-4070)

2) iax2_call() has the following code
    if (secret[0] == '[') {
        /* This is an RSA key, not a normal secret */
        ast_copy_string(iaxs[callno]->outkey,secret + 1,
--->                   sizeof(iaxs[callno]->secret));
        if (!ast_strlen_zero(iaxs[callno]->outkey)) {
             iaxs[callno]->outkey[strlen(iaxs[callno]->outkey) - 1] = '\0';

   which has wrong size supplied in the line ---> (once again, by using
   macros as the one in ASTERISK-4070 one could not introduce such bugs) and
   the same useless termination check as above in the second if (...)


patch unnecessary given that the fix is trivial as discussed above.
Comments:By: Clod Patry (junky) 2005-05-30 06:57:48

My opinion is: it's always good to have patches rizzo.

By: Mark Spencer (markster) 2005-05-30 09:54:30

#1 is not a NOP, it simply removes the last "|" symbol.

#2 Fixed in CVS head.

By: Michael Jerris (mikej) 2005-05-31 00:46:12

Patch for stable, disclaimer on file.

By: Olle Johansson (oej) 2005-05-31 00:54:09

Please report bugs in the proper category. IAX2 is not [Core Asterisk] ;-)

By: Russell Bryant (russell) 2005-05-31 08:56:11

fixed in 1.0

By: Digium Subversion (svnbot) 2008-01-15 15:36:22.000-0600

Repository: asterisk
Revision: 5788

U   trunk/channels/chan_iax2.c

r5788 | markster | 2008-01-15 15:36:22 -0600 (Tue, 15 Jan 2008) | 2 lines

Fix small sizeof bug (ASTERISK-4299)