Text   |  XML   |  ReML   |   Visible Warnings:

Redundant Condition  at to_str.c:105

No properties have been set. | edit properties
Jump to warning location ↓ warning details...
Show Events | Options

bytestring_to_str

(/home/sate/Testcases/c/cve/wireshark-1.2.0/epan/to_str.c)expand/collapse
Show more  
 83  gchar *
 84  bytestring_to_str(const guint8 *ad, guint32 len, char punct) {
 85    gchar *buf;
 86    gchar        *p;
 87    int          i = (int) len - 1;
 88    guint32      octet;
 89    size_t       buflen;
 90    /* At least one version of Apple's C compiler/linker is buggy, causing 
 91       a complaint from the linker about the "literal C string section"
 92       not ending with '\0' if we initialize a 16-element "char" array with
 93       a 16-character string, the fact that initializing such an array with
 94       such a string is perfectly legitimate ANSI C nonwithstanding, the 17th
 95       '\0' byte in the string nonwithstanding. */
 96    static const gchar hex_digits[16] =
 97        { '0', '1', '2', '3', '4', '5', '6', '7',
 98          '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
 99   
 100    if (punct)
 101      buflen=len*3;
 102    else 
 103      buflen=len*2 + 1;
 104   
 105    if (buflen < 3 || i < 0) {
 106      return "";
 107    }
 108   
 109    buf=ep_alloc(buflen);
 110    p = &buf[buflen - 1];
 111    *p = '\0';
 112    for (;;) {
 113      octet = ad[i];
 114      *--p = hex_digits[octet&0xF];
 115      octet >>= 4;
 116      *--p = hex_digits[octet&0xF];
 117      if (i <= 0)
 118        break;
 119      if (punct)
 120        *--p = punct;
 121      i--;
 122    }
 123    return p;
 124  }
Show more  




Change Warning 1211.30215 : Redundant Condition

Priority:
State:
Finding:
Owner:
Note: