Text   |  XML   |  ReML   |   Visible Warnings:

Ignored Return Value  at visual.c:865

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

visual_dump_close

(/home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/visual.c)expand/collapse
Show more  
 830  static gboolean visual_dump_close(wtap_dumper *wdh, int *err)
 831  {
 832      struct visual_write_info * visual = wdh->dump.opaque;
 833      size_t n_to_write;
 834      size_t nwritten;
 835      struct visual_file_hdr vfile_hdr;
 836      const char *magicp;
 837      size_t magic_size;
 838   
 839      /* If the visual structure was never allocated then nothing useful
 840         can be done. */
 841      if (visual == 0)
 842          return FALSE;
 843   
 844      /* Write out the frame table at the end of the file. */
 845      if (visual->index_table)
 846      {
 847          /* Write the index table to the file. */
 848          n_to_write = visual->index_table_index * sizeof *visual->index_table;
 849          nwritten = fwrite(visual->index_table, 1, n_to_write, wdh->fh);
 850          if (nwritten != n_to_write)
 851          {
 852              if (err != NULL)
 853              {
 854                  if (nwritten == 0 && ferror(wdh->fh))
 855                      *err = errno;
 856                  else 
 857                      *err = WTAP_ERR_SHORT_WRITE;
 858              }
 859              visual_dump_free(wdh);
 860              return FALSE;
 861          }
 862      }
 863   
 864      /* Write the magic number at the start of the file. */
 865      fseek(wdh->fh, 0, SEEK_SET);
 866      magicp = visual_magic;
 867      magic_size = sizeof visual_magic;
 868      nwritten = fwrite(magicp, 1, magic_size, wdh->fh);
 869      if (nwritten != magic_size)
 870      {
 871          if (err != NULL)
 872          {
 873              if (nwritten == 0 && ferror(wdh->fh))
 874                  *err = errno;
 875              else 
 876                  *err = WTAP_ERR_SHORT_WRITE;
 877          }
 878          visual_dump_free(wdh);
 879          return FALSE;
 880      }
 881   
 882      /* Initialize the file header with zeroes for the reserved fields. */
 883      memset(&vfile_hdr, '\0', sizeof vfile_hdr);
 884      vfile_hdr.num_pkts = htolel(visual->index_table_index);
 885      vfile_hdr.start_time = htolel(visual->start_time);
 886      vfile_hdr.max_length = htoles(65535);
 887      vfile_hdr.file_flags = htoles(1);  /* indexes are present */
 888      vfile_hdr.file_version = htoles(1);
 889      g_strlcpy(vfile_hdr.description, "Wireshark file", 64);
 890   
 891      /* Translate the encapsulation type */
 892      switch (wdh->encap)
 893      {
 894      case WTAP_ENCAP_ETHERNET:
 895          vfile_hdr.media_type = htoles(6);
 896          break;
 897   
 898      case WTAP_ENCAP_TOKEN_RING:
 899          vfile_hdr.media_type = htoles(9);
 900          break;
 901   
 902      case WTAP_ENCAP_LAPB:
 903          vfile_hdr.media_type = htoles(16);
 904          break;
 905   
 906      case WTAP_ENCAP_PPP:        /* PPP is differentiated from CHDLC in PktHdr */
 907      case WTAP_ENCAP_PPP_WITH_PHDR:
 908      case WTAP_ENCAP_CHDLC_WITH_PHDR:
 909          vfile_hdr.media_type = htoles(22);
 910          break;
 911   
 912      case WTAP_ENCAP_FRELAY_WITH_PHDR:
 913          vfile_hdr.media_type = htoles(32);
 914          break;
 915      }
 916   
 917      /* Write the file header following the magic bytes. */
 918      nwritten = fwrite(&vfile_hdr, 1, sizeof vfile_hdr, wdh->fh);
 919      if (nwritten != sizeof vfile_hdr)
 920      {
 921          if (err != NULL)
 922          {
 923              if (nwritten == 0 && ferror(wdh->fh))
 924                  *err = errno;
 925              else 
 926                  *err = WTAP_ERR_SHORT_WRITE;
 927          }
 928          visual_dump_free(wdh);
 929          return FALSE;
 930      }
 931   
 932      /* Deallocate the file write data */
 933      visual_dump_free(wdh);
 934      return TRUE;
 935  }
Show more  




Change Warning 5501.35773 : Ignored Return Value

Priority:
State:
Finding:
Owner:
Note: