(/home/sate/Testcases/c/cve/wireshark-1.2.0/epan/dissectors/packet-tftp.c) |
| |
| 159 | | | static void dissect_tftp_message(tftp_conv_info_t *tftp_info, |
| 160 | | | tvbuff_t *tvb, packet_info *pinfo, |
| 161 | | | proto_tree *tree) |
| 162 | | | { |
| 163 | | | proto_tree *tftp_tree = NULL; |
| 164 | | | proto_item *ti; |
| 165 | | | gint offset = 0; |
| 166 | | | guint16 opcode; |
| 167 | | | guint16 bytes; |
| 168 | | | guint16 blocknum; |
| 169 | | | guint i1; |
| 170 | | | guint16 error; |
| 171 | | | |
| 172 | | | if (check_col(pinfo->cinfo, COL_PROTOCOL)) |
| 173 | | | col_set_str(pinfo->cinfo, COL_PROTOCOL, "TFTP"); |
| 174 | | | |
| 175 | | | opcode = tvb_get_ntohs(tvb, offset); |
| 176 | | | |
| 177 | | | if (check_col(pinfo->cinfo, COL_INFO)) { |
| 178 | | | |
| 179 | | | col_add_str(pinfo->cinfo, COL_INFO, |
| 180 | | | val_to_str(opcode, tftp_opcode_vals, "Unknown (0x%04x)")); |
| 181 | | | |
| 182 | | | } |
| 183 | | | |
| 184 | | | if (tree) { |
| 185 | | | |
| 186 | | | ti = proto_tree_add_item(tree, proto_tftp, tvb, offset, -1, FALSE); |
| 187 | | | tftp_tree = proto_item_add_subtree(ti, ett_tftp); |
| 188 | | | |
| 189 | | | if(tftp_info->source_file) { |
| 190 | | | ti = proto_tree_add_string(tftp_tree, hf_tftp_source_file, tvb, |
| 191 | | | 0, 0, tftp_info->source_file); |
| 192 | | | 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) |
| |
|
| 193 | | | } |
| 194 | | | |
| 195 | | | if(tftp_info->destination_file) { |
| 196 | | | ti = proto_tree_add_string(tftp_tree, hf_tftp_destination_file, tvb, |
| 197 | | | 0, 0, tftp_info->destination_file); |
| 198 | | | 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) |
| |
|
| 199 | | | } |
| 200 | | | |
| 201 | | | proto_tree_add_uint(tftp_tree, hf_tftp_opcode, tvb, |
| 202 | | | offset, 2, opcode); |
| 203 | | | } |
| 204 | | | offset += 2; |
| 205 | | | |
| 206 | | | switch (opcode) { |
| 207 | | | |
| 208 | | | case TFTP_RRQ: |
| 209 | | | i1 = tvb_strsize(tvb, offset); |
| 210 | | | if (tree) { |
| 211 | | | proto_tree_add_item(tftp_tree, hf_tftp_source_file, |
| 212 | | | tvb, offset, i1, FALSE); |
| 213 | | | } |
| 214 | | | |
| 215 | | | tftp_info->source_file = tvb_get_seasonal_string(tvb, offset, i1); |
| 216 | | | |
| 217 | | | if (check_col(pinfo->cinfo, COL_INFO)) { |
| 218 | | | col_append_fstr(pinfo->cinfo, COL_INFO, ", File: %s", |
| 219 | | | tvb_format_text(tvb, offset, i1)); |
| 220 | | | } |
| 221 | | | offset += i1; |
| 222 | | | |
| 223 | | | i1 = tvb_strsize(tvb, offset); |
| 224 | | | if (tree) { |
| 225 | | | ti = proto_tree_add_item(tftp_tree, hf_tftp_transfer_type, |
| 226 | | | tvb, offset, i1, FALSE); |
| 227 | | | } |
| 228 | | | if (check_col(pinfo->cinfo, COL_INFO)) { |
| 229 | | | col_append_fstr(pinfo->cinfo, COL_INFO, ", Transfer type: %s", |
| 230 | | | tvb_format_text(tvb, offset, i1)); |
| 231 | | | } |
| 232 | | | offset += i1; |
| 233 | | | |
| 234 | | | if (tree) |
| 235 | | | tftp_dissect_options(tvb, pinfo, offset, tftp_tree, |
| 236 | | | opcode, tftp_info); |
| 237 | | | break; |
| 238 | | | |
| 239 | | | case TFTP_WRQ: |
| 240 | | | i1 = tvb_strsize(tvb, offset); |
| 241 | | | if (tree) { |
| 242 | | | proto_tree_add_item(tftp_tree, hf_tftp_destination_file, |
| 243 | | | tvb, offset, i1, FALSE); |
| 244 | | | } |
| 245 | | | |
| 246 | | | tftp_info->destination_file = |
| 247 | | | tvb_get_seasonal_string(tvb, offset, i1); |
| 248 | | | |
| 249 | | | if (check_col(pinfo->cinfo, COL_INFO)) { |
| 250 | | | col_append_fstr(pinfo->cinfo, COL_INFO, ", File: %s", |
| 251 | | | tvb_format_text(tvb, offset, i1)); |
| 252 | | | } |
| 253 | | | offset += i1; |
| 254 | | | |
| 255 | | | i1 = tvb_strsize(tvb, offset); |
Ignored Return Value
The return value of tvb_strsize() 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 tvb_strsize() is checked 99% 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 tvb_strsize() from the Ignored Return Value check, use configuration file parameter RETURN_CHECKER_IGNORED_FUNCS).
Show: All events | Only primary events |
|
| 256 | | | if (tree) { |
Event 2:
Skipping " if". tree evaluates to false.
hide
|
|
| 257 | | | ti = proto_tree_add_item(tftp_tree, hf_tftp_transfer_type, |
| 258 | | | tvb, offset, i1, FALSE); |
| 259 | | | } |
| 260 | | | |
| 261 | | | if (check_col(pinfo->cinfo, COL_INFO)) { |
Event 3:
Skipping " if". check_col(...) evaluates to false.
hide
|
|
| 262 | | | col_append_fstr(pinfo->cinfo, COL_INFO, ", Transfer type: %s", |
| 263 | | | tvb_format_text(tvb, offset, i1)); |
| 264 | | | } |
| 265 | | | offset += i1; |
| 266 | | | |
| 267 | | | if (tree) |
Event 4:
Skipping " if". tree evaluates to false.
hide
|
|
| 268 | | | tftp_dissect_options(tvb, pinfo, offset, tftp_tree, |
| 269 | | | opcode, tftp_info); |
| 270 | | | break; |
| 271 | | | |
| 272 | | | case TFTP_INFO: |
| 273 | | | if (tree) |
| 274 | | | tftp_dissect_options(tvb, pinfo, offset, tftp_tree, |
| 275 | | | opcode, tftp_info); |
| 276 | | | break; |
| 277 | | | |
| 278 | | | case TFTP_DATA: |
| 279 | | | blocknum = tvb_get_ntohs(tvb, offset); |
| 280 | | | if (tree) { |
| 281 | | | proto_tree_add_uint(tftp_tree, hf_tftp_blocknum, tvb, offset, 2, |
| 282 | | | blocknum); |
| 283 | | | } |
| 284 | | | offset += 2; |
| 285 | | | |
| 286 | | | bytes = tvb_reported_length_remaining(tvb, offset); |
| 287 | | | |
| 288 | | | if (check_col(pinfo->cinfo, COL_INFO)) { |
| 289 | | | col_append_fstr(pinfo->cinfo, COL_INFO, ", Block: %i%s", |
| 290 | | | blocknum, |
| 291 | | | (bytes < tftp_info->blocksize)?" (last)":"" ); |
| 292 | | | } |
| 293 | | | |
| 294 | | | if (bytes != 0) { |
| 295 | | | if (tree) { |
| 296 | | | proto_tree_add_text(tftp_tree, tvb, offset, -1, |
| 297 | | | "Data (%d bytes)", bytes); |
| 298 | | | } |
| 299 | | | } |
| 300 | | | break; |
| 301 | | | |
| 302 | | | case TFTP_ACK: |
| 303 | | | blocknum = tvb_get_ntohs(tvb, offset); |
| 304 | | | if (tree) { |
| 305 | | | proto_tree_add_uint(tftp_tree, hf_tftp_blocknum, tvb, offset, 2, |
| 306 | | | blocknum); |
| 307 | | | } |
| 308 | | | if (check_col(pinfo->cinfo, COL_INFO)) { |
| 309 | | | col_append_fstr(pinfo->cinfo, COL_INFO, ", Block: %i", |
| 310 | | | blocknum); |
| 311 | | | } |
| 312 | | | break; |
| 313 | | | |
| 314 | | | case TFTP_ERROR: |
| 315 | | | error = tvb_get_ntohs(tvb, offset); |
| 316 | | | if (tree) { |
| 317 | | | proto_tree_add_uint(tftp_tree, hf_tftp_error_code, tvb, offset, 2, |
| 318 | | | error); |
| 319 | | | } |
| 320 | | | if (check_col(pinfo->cinfo, COL_INFO)) { |
| 321 | | | col_append_fstr(pinfo->cinfo, COL_INFO, ", Code: %s", |
| 322 | | | val_to_str(error, tftp_error_code_vals, "Unknown (%u)")); |
| 323 | | | } |
| 324 | | | offset += 2; |
| 325 | | | |
| 326 | | | i1 = tvb_strsize(tvb, offset); |
| 327 | | | if (tree) { |
| 328 | | | proto_tree_add_item(tftp_tree, hf_tftp_error_string, tvb, offset, |
| 329 | | | i1, FALSE); |
| 330 | | | } |
| 331 | | | if (check_col(pinfo->cinfo, COL_INFO)) { |
| 332 | | | col_append_fstr(pinfo->cinfo, COL_INFO, ", Message: %s", |
| 333 | | | tvb_format_text(tvb, offset, i1)); |
| 334 | | | } |
| 335 | | | expert_add_info_format(pinfo, NULL, PI_RESPONSE_CODE, |
| 336 | | | PI_NOTE, "TFTP blocksize out of range"); |
| 337 | | | break; |
| 338 | | | |
| 339 | | | case TFTP_OACK: |
| 340 | | | if (tree) |
| 341 | | | tftp_dissect_options(tvb, pinfo, offset, tftp_tree, |
| 342 | | | opcode, tftp_info); |
| 343 | | | break; |
| 344 | | | |
| 345 | | | default: |
| 346 | | | if (tree) { |
| 347 | | | proto_tree_add_text(tftp_tree, tvb, offset, -1, |
| 348 | | | "Data (%d bytes)", tvb_reported_length_remaining(tvb, offset)); |
| 349 | | | } |
| 350 | | | break; |
| 351 | | | |
| 352 | | | } |
| 353 | | | return; |
| 354 | | | } |
| |