(/home/sate/Testcases/c/cve/wireshark-1.2.0/epan/dissectors/packet-fcoe.c) |
| |
| 114 | | | dissect_fcoe(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) |
| 115 | | | { |
| 116 | | | gint crc_offset; |
| 117 | | | gint eof_offset; |
| 118 | | | gint frame_len = 0; |
| 119 | | | gint = ; |
| 120 | | | guint version; |
| 121 | | | const char *ver; |
| 122 | | | guint16 len_sof; |
| 123 | | | gint bytes_remaining; |
| 124 | | | guint8 sof = 0; |
| 125 | | | guint8 eof = 0; |
| 126 | | | const char *eof_str; |
| 127 | | | const char *crc_msg; |
| 128 | | | const char *len_msg; |
| 129 | | | proto_item *ti; |
| 130 | | | proto_item *item; |
| 131 | | | proto_tree *fcoe_tree = NULL; |
| 132 | | | proto_tree *crc_tree; |
| 133 | | | tvbuff_t *next_tvb; |
| 134 | | | gboolean crc_exists; |
| 135 | | | guint32 crc_computed = 0; |
| 136 | | | guint32 crc = 0; |
| 137 | | | |
| 138 | | | |
| 139 | | | |
| 140 | | | |
| 141 | | | |
| 142 | | | |
| 143 | | | if (tvb_get_guint8(tvb, 1)) { |
| 144 | | | = 2; |
| 145 | | | len_sof = tvb_get_ntohs(tvb, 0); |
| 146 | | | frame_len = ((len_sof & 0x3ff0) >> 2) - 4; |
| 147 | | | sof = len_sof & 0xf; |
| 148 | | | sof |= (sof < 8) ? 0x30 : 0x20; |
| 149 | | | version = len_sof >> 14; |
| 150 | | | ver = "pre-T11 "; |
| 151 | | | if (version != 0) |
| 152 | | | ver = ep_strdup_printf(ver, "pre-T11 ver %d ", version); |
Ignored Return Value
The return value of ep_strdup_printf() is never checked in the highlighted execution scenario. - If the return value can indicate an error, the error will be ignored if the highlighted code executes.
- The return value of ep_strdup_printf() is checked 97% of the time in this project. CodeSonar is configured to enforce Ignored Return Value checks for any function whose return value is checked at least 96% of the time, unless the function is used fewer than 20 times. (To modify these thresholds, use configuration file parameters RETURN_CHECKER_SAMPLE_SIZE and RETURN_CHECKER_RATIO. To exempt ep_strdup_printf() from the Ignored Return Value check, use configuration file parameter RETURN_CHECKER_IGNORED_FUNCS).
Show: All events | Only primary events |
|
| 153 | | | } else { |
| 154 | | | frame_len = tvb_reported_length_remaining(tvb, 0) - |
| 155 | | | - FCOE_TRAILER_LEN; |
| 156 | | | sof = tvb_get_guint8(tvb, - 1); |
| 157 | | | |
| 158 | | | |
| 159 | | | |
| 160 | | | |
| 161 | | | |
| 162 | | | ver = ""; |
| 163 | | | version = tvb_get_guint8(tvb, 0) >> 4; |
| 164 | | | if (version != 0) |
| 165 | | | ver = ep_strdup_printf(ver, "ver %d ", version); |
| 166 | | | } |
| 167 | | | if (check_col(pinfo->cinfo, COL_PROTOCOL)) |
Event 2:
Taking true branch. check_col(...) evaluates to true.
hide
|
|
| 168 | | | col_set_str(pinfo->cinfo, COL_PROTOCOL, "FCoE"); |
| 169 | | | crc_offset = + frame_len; |
| 170 | | | eof_offset = crc_offset + 4; |
| 171 | | | bytes_remaining = tvb_length_remaining(tvb, ); |
| 172 | | | if (bytes_remaining > frame_len) |
Event 3:
Taking true branch. bytes_remaining > frame_len evaluates to true.
hide
|
|
| 173 | | | bytes_remaining = frame_len; |
| 174 | | | next_tvb = tvb_new_subset(tvb, , bytes_remaining, frame_len); |
| 175 | | | |
| 176 | | | if (tree) { |
Event 4:
Skipping " if". tree evaluates to false.
hide
|
|
| 177 | | | |
| 178 | | | eof_str = "none"; |
| 179 | | | if (tvb_bytes_exist(tvb, eof_offset, 1)) { |
| 180 | | | eof = tvb_get_guint8(tvb, eof_offset); |
| 181 | | | eof_str = val_to_str(eof, fcoe_eof_vals, "0x%x"); |
| 182 | | | } |
| 183 | | | |
| 184 | | | |
| 185 | | | |
| 186 | | | |
| 187 | | | crc_msg = ""; |
| 188 | | | crc_exists = tvb_bytes_exist(tvb, crc_offset, 4); |
| 189 | | | if (crc_exists) { |
| 190 | | | crc = tvb_get_ntohl(tvb, crc_offset); |
| 191 | | | crc_computed = crc32_802_tvb(next_tvb, frame_len); |
| 192 | | | if (crc != crc_computed) { |
| 193 | | | crc_msg = " [bad FC CRC]"; |
| 194 | | | } |
| 195 | | | } |
| 196 | | | len_msg = ""; |
| 197 | | | if ((frame_len % 4) != 0 || frame_len < 24) { |
| 198 | | | len_msg = " [invalid length]"; |
| 199 | | | } |
| 200 | | | |
| 201 | | | ti = proto_tree_add_protocol_format(tree, proto_fcoe, tvb, 0, |
| 202 | | | , |
| 203 | | | "FCoE %s(%s/%s) %d bytes%s%s", ver, |
| 204 | | | val_to_str(sof, fcoe_sof_vals, |
| 205 | | | "0x%x"), |
| 206 | | | eof_str, frame_len, crc_msg, |
| 207 | | | len_msg); |
| 208 | | | |
| 209 | | | |
| 210 | | | |
| 211 | | | fcoe_tree = proto_item_add_subtree(ti, ett_fcoe); |
| 212 | | | proto_tree_add_uint(fcoe_tree, hf_fcoe_ver, tvb, 0, 1, version); |
| 213 | | | if (tvb_get_guint8(tvb, 1)) { |
| 214 | | | proto_tree_add_uint(fcoe_tree, hf_fcoe_len, tvb, 0, 2, frame_len); |
| 215 | | | } |
| 216 | | | proto_tree_add_uint(fcoe_tree, hf_fcoe_sof, tvb, |
| 217 | | | - 1, 1, sof); |
| 218 | | | |
| 219 | | | |
| 220 | | | |
| 221 | | | |
| 222 | | | if (crc_exists) { |
| 223 | | | if (crc == crc_computed) { |
| 224 | | | item = proto_tree_add_uint_format(fcoe_tree, hf_fcoe_crc, tvb, |
| 225 | | | crc_offset, 4, crc, |
| 226 | | | "CRC: %8.8x [valid]", crc); |
| 227 | | | } else { |
| 228 | | | item = proto_tree_add_uint_format(fcoe_tree, hf_fcoe_crc, tvb, |
| 229 | | | crc_offset, 4, crc, |
| 230 | | | "CRC: %8.8x " |
| 231 | | | "[error: should be %8.8x]", |
| 232 | | | crc, crc_computed); |
| 233 | | | expert_add_info_format(pinfo, item, PI_CHECKSUM, PI_ERROR, |
| 234 | | | "Bad FC CRC %8.8x %8.x", |
| 235 | | | crc, crc_computed); |
| 236 | | | } |
| 237 | | | proto_tree_set_appendix(fcoe_tree, tvb, crc_offset, |
| 238 | | | tvb_length_remaining (tvb, crc_offset)); |
| 239 | | | } else { |
| 240 | | | item = proto_tree_add_text(fcoe_tree, tvb, crc_offset, 0, |
| 241 | | | "CRC: [missing]"); |
| 242 | | | } |
| 243 | | | crc_tree = proto_item_add_subtree(item, ett_fcoe_crc); |
| 244 | | | ti = proto_tree_add_boolean(crc_tree, hf_fcoe_crc_bad, tvb, |
| 245 | | | crc_offset, 4, |
| 246 | | | crc_exists && crc != crc_computed); |
| 247 | | | PROTO_ITEM_SET_GENERATED(ti);
x /home/sate/Testcases/c/cve/wireshark-1.2.0/epan/proto.h |
| |
325 | #define PROTO_ITEM_SET_GENERATED(proto_item) \ |
326 | ((proto_item) ? FI_SET_FLAG((proto_item)->finfo, FI_GENERATED) : 0) |
| |
x /home/sate/Testcases/c/cve/wireshark-1.2.0/epan/proto.h |
| |
246 | #define FI_SET_FLAG(fi, flag) (fi->flags = fi->flags | flag) |
| |
|
| 248 | | | ti = proto_tree_add_boolean(crc_tree, hf_fcoe_crc_good, tvb, |
| 249 | | | crc_offset, 4, |
| 250 | | | crc_exists && crc == crc_computed); |
| 251 | | | PROTO_ITEM_SET_GENERATED(ti);
x /home/sate/Testcases/c/cve/wireshark-1.2.0/epan/proto.h |
| |
325 | #define PROTO_ITEM_SET_GENERATED(proto_item) \ |
326 | ((proto_item) ? FI_SET_FLAG((proto_item)->finfo, FI_GENERATED) : 0) |
| |
x /home/sate/Testcases/c/cve/wireshark-1.2.0/epan/proto.h |
| |
246 | #define FI_SET_FLAG(fi, flag) (fi->flags = fi->flags | flag) |
| |
|
| 252 | | | |
| 253 | | | |
| 254 | | | |
| 255 | | | |
| 256 | | | if (tvb_bytes_exist(tvb, eof_offset, 1)) { |
| 257 | | | proto_tree_add_item(fcoe_tree, hf_fcoe_eof, tvb, eof_offset, 1, 0); |
| 258 | | | } |
| 259 | | | } |
| 260 | | | |
| 261 | | | |
| 262 | | | pinfo->sof_eof = 0; |
| 263 | | | if (sof == FCOE_SOFi3 || sof == FCOE_SOFi2 || sof == FCOE_SOFi4) { |
| 264 | | | pinfo->sof_eof = PINFO_SOF_FIRST_FRAME; |
| 265 | | | } else if (sof == FCOE_SOFf) { |
Event 6:
Taking true branch. sof == FCOE_SOFf evaluates to true.
hide
|
|
| 266 | | | pinfo->sof_eof = PINFO_SOF_SOFF; |
| 267 | | | } |
| 268 | | | |
| 269 | | | if (eof != FCOE_EOFn) { |
Event 7:
Taking true branch. eof != FCOE_EOFn evaluates to true.
hide
|
|
| 270 | | | pinfo->sof_eof |= PINFO_EOF_LAST_FRAME; |
| 271 | | | } else if (eof != FCOE_EOFt) { |
| 272 | | | pinfo->sof_eof |= PINFO_EOF_INVALID; |
| 273 | | | } |
| 274 | | | |
| 275 | | | |
| 276 | | | |
| 277 | | | if (fc_handle) { |
Event 8:
Taking false branch. fc_handle evaluates to false.
hide
|
|
| 278 | | | call_dissector(fc_handle, next_tvb, pinfo, tree); |
| 279 | | | } else if (data_handle) { |
Event 9:
Taking true branch. data_handle evaluates to true.
hide
|
|
| 280 | | | call_dissector(data_handle, next_tvb, pinfo, tree); |
| 281 | | | } |
| 282 | | | } |
| |