Text   |  XML   |  ReML   |   Visible Warnings:

Redundant Condition  at pcapio.c:350

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

libpcap_write_interface_description_block

(/home/sate/Testcases/c/cve/wireshark-1.2.0/pcapio.c)expand/collapse
Show more  
 316  libpcap_write_interface_description_block(FILE *fp,
 317                                            char *name,
 318                                            char *filter,
 319                                            int link_type,
 320                                            int snap_len,
 321                                            long *bytes_written,
 322                                            int *err)
 323  {
 324          struct idb idb;
 325          struct option option;
 326          guint32 block_total_length;
 327          const guint32 padding = 0;
 328   
 329          block_total_length = sizeof(struct idb) + sizeof(guint32);
 330          if ((strlen(name) > 0) && (strlen(name) < G_MAXUINT16)) {
 331                  block_total_length += sizeof(struct option) +  
 332                                        (guint16)(ADD_PADDING(strlen(name) + 1));
 333          }
 334          if ((strlen(filter) > 0) && (strlen(name) < G_MAXUINT16)) {
 335                  block_total_length += sizeof(struct option) +
 336                                        (guint16)(ADD_PADDING(strlen(filter) + 1));
 337          }
 338          if (((strlen(name) > 0) && (strlen(name) < G_MAXUINT16)) ||
 339              ((strlen(filter) > 0) && (strlen(name) < G_MAXUINT16))) {
 340                  block_total_length += sizeof(struct option);
 341          }
 342          /* write block header */
 343          idb.block_type = INTERFACE_DESCRIPTION_BLOCK_TYPE;
 344          idb.block_total_length = block_total_length;
 345          idb.link_type = link_type;
 346          idb.reserved = 0;
 347          idb.snap_len = snap_len;
 348          WRITE_DATA(fp, &idb, sizeof(struct idb), *bytes_written, err);
 349          /* write interface name string if applicable */
 350          if ((strlen(name) > 0) && (strlen(name) < G_MAXUINT16)) {
 351                  option.type = IDB_NAME;
 352                  option.value_length = (guint16)(strlen(name) + 1);
 353                  WRITE_DATA(fp, &option, sizeof(struct option), *bytes_written, err);
 354                  WRITE_DATA(fp, name, strlen(name) + 1, *bytes_written, err);
 355                  if ((strlen(name) + 1) % 4) {
 356                          WRITE_DATA(fp, &padding, 4 - (strlen(name) + 1) % 4 , *bytes_written, err);
 357                  }
 358          }
 359          /* write filter string if applicable */
 360          if ((strlen(filter) > 0) && (strlen(filter) < G_MAXUINT16)) {
 361                  option.type = IDB_FILTER;
 362                  option.value_length = (guint16)(strlen(filter) + 1);
 363                  WRITE_DATA(fp, &option, sizeof(struct option), *bytes_written, err);
 364                  WRITE_DATA(fp, filter, strlen(filter) + 1, *bytes_written, err);
 365                  if ((strlen(filter) + 1) % 4) {
 366                          WRITE_DATA(fp, &padding, 4 - (strlen(filter) + 1) % 4 , *bytes_written, err);
 367                  }
 368          }
 369          /* write endofopt option if there were any options */
 370          if (((strlen(name) > 0) && (strlen(name) < G_MAXUINT16)) ||
 371              ((strlen(filter) > 0) && (strlen(filter) < G_MAXUINT16))) {
 372                  option.type = OPT_ENDOFOPT;
 373                  option.value_length = 0;
 374                  WRITE_DATA(fp, &option, sizeof(struct option), *bytes_written, err);
 375          }
 376          /* write the trailing Block Total Length */
 377          WRITE_DATA(fp, &block_total_length, sizeof(guint32), *bytes_written, err);
 378          return TRUE;
 379  }
Show more  




Change Warning 5016.29771 : Redundant Condition

Because they are very similar, this warning shares annotations with warning 5016.29775.

Priority:
State:
Finding:
Owner:
Note: