[asterisk-bugs] [JIRA] (ASTERISK-21772) Code reading revealed useless if statement

Alec Davis (JIRA) noreply at issues.asterisk.org
Thu May 9 03:38:38 CDT 2013


    [ https://issues.asterisk.org/jira/browse/ASTERISK-21772?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=206213#comment-206213 ] 

Alec Davis commented on ASTERISK-21772:
---------------------------------------

Under 'More Actions' you'll find 'Attach Files'.
                
> Code reading revealed useless if statement
> ------------------------------------------
>
>                 Key: ASTERISK-21772
>                 URL: https://issues.asterisk.org/jira/browse/ASTERISK-21772
>             Project: Asterisk
>          Issue Type: Improvement
>      Security Level: None
>    Affects Versions: SVN
>            Reporter: Peter J. Philipp
>            Severity: Minor
>
> In code reading dns.c I see this:
>                 if (len < 0) {
>                         ast_log(LOG_WARNING, "Strange result size\n");
>                         return -1;
>                 }
>                 if (len < 0) {
>                         ast_log(LOG_WARNING, "Length exceeds frame\n");
>                         return -1;
>                 }
> 1. the second if will always be false if it's called
> 2. adds useless check, since first already covers it
> I don't see a patch upload field here so here goes the patch:
> --- dns.c.orig  Thu May  9 10:06:09 2013
> +++ dns.c       Thu May  9 10:06:50 2013
> @@ -221,13 +221,13 @@
>                 }
>                 answer += res;
>                 len -= res;
> -               ans = (struct dn_answer *)answer;
> -               answer += sizeof(struct dn_answer);
> -               len -= sizeof(struct dn_answer);
>                 if (len < 0) {
>                         ast_log(LOG_WARNING, "Strange result size\n");
>                         return -1;
>                 }
> +               ans = (struct dn_answer *)answer;
> +               answer += sizeof(struct dn_answer);
> +               len -= sizeof(struct dn_answer);
>                 if (len < 0) {
>                         ast_log(LOG_WARNING, "Length exceeds frame\n");
>                         return -1;

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.asterisk.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira



More information about the asterisk-bugs mailing list