Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ospf6d: remove redundant null ptr check #17363

Commits on Nov 6, 2024

  1. ospf6d: remove redundant null ptr check

    Fix defect flagged by Coverity:
    
    *** CID 1599962:  Null pointer dereferences  (REVERSE_INULL)
    /ospf6d/ospf6_intra.c: 775 in ospf6_intra_prefix_lsa_get_prefix_str()
    769     {
    770             struct ospf6_prefix *prefix = nth_prefix(lsa->header, pos);
    771             struct in6_addr in6 = { 0 };
    772             char tbuf[16];
    773
    774             /* ensure buflen >= INET6_ADDRSTRLEN + '/128\0' */
    >>>     CID 1599962:  Null pointer dereferences  (REVERSE_INULL)
    >>>     Null-checking "lsa" suggests that it may be null, but it has already been dereferenced on all paths leading to the check.
    775             if (!lsa || !prefix || !buf || buflen < (5 + INET6_ADDRSTRLEN))
    776                     return NULL;
    777
    778             memcpy(&in6, OSPF6_PREFIX_BODY(prefix),
    779                    OSPF6_PREFIX_SPACE(prefix->prefix_length));
    780             inet_ntop(AF_INET6, &in6, buf, buflen);
    
    The check for lsa being not-null happens in ospf6_lsdb_show() and
    first dereference happens in ospf6_lsa_show_summary()
    
    Signed-off-by: Andrew Cooks <[email protected]>
    acooks-at-bda committed Nov 6, 2024
    Configuration menu
    Copy the full SHA
    24d8d95 View commit details
    Browse the repository at this point in the history