Text   |  XML   |  ReML   |   Visible Warnings:

Cast Alters Value  at follow_stream.c:1045

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

follow_read_tcp_stream

(/home/sate/Testcases/c/cve/wireshark-1.2.0/gtk/follow_tcp.c)expand/collapse
Show more  
 329  follow_read_tcp_stream(follow_info_t *follow_info,
 330                         gboolean (*print_line)(char *, size_t, gboolean, void *),
 331                         void *arg)
 332  {
 333      tcp_stream_chunk    sc;
 334      int                 bcount, iplen;
 335      guint8              client_addr[MAX_IPADDR_LEN];
 336      guint16             client_port = 0;
 337      gboolean            is_server;
 338      guint32             global_client_pos = 0, global_server_pos = 0;
 339      guint32             server_packet_count = 0;
 340      guint32             client_packet_count = 0;
 341      guint32             *global_pos;
 342      gboolean            skip;
 343      char                buffer[FLT_BUF_SIZE+1]; /* +1 to fix ws bug 1043 */
 344      size_t              nchars;
 345      frs_return_t        frs_return;
 346   
 347      iplen = (follow_info->is_ipv6) ? 16 : 4;
 348   
 349      data_out_file = ws_fopen(follow_info->data_out_filename, "rb");
 350      if (data_out_file == NULL) {
 351          simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
 352                        "Could not open temporary file %s: %s", follow_info->data_out_filename,
 353                        strerror(errno));
 354          return FRS_OPEN_ERROR;
 355      }
 356   
 357      while ((nchars=fread(&sc, 1, sizeof(sc), data_out_file))) {
 358          if (nchars != sizeof(sc)) {
 359              simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
 360                            "Short read from temporary file %s: expected %lu, got %lu",
 361                            follow_info->data_out_filename,
 362                            (unsigned long)sizeof(sc),
 363                            (unsigned long)nchars);
 364              fclose(data_out_file);
 365              data_out_file = NULL;
 366              return FRS_READ_ERROR;
 367          }
 368          if (client_port == 0) {
 369              memcpy(client_addr, sc.src_addr, iplen);
 370              client_port = sc.src_port;
 371          }
 372          skip = FALSE;
 373          if (memcmp(client_addr, sc.src_addr, iplen) == 0 &&
 374              client_port == sc.src_port) {
 375              is_server = FALSE;
 376              global_pos = &global_client_pos;
 377              if (follow_info->show_stream == FROM_SERVER) {
 378                  skip = TRUE;
 379              }
 380          }
 381          else {
 382              is_server = TRUE;
 383              global_pos = &global_server_pos;
 384              if (follow_info->show_stream == FROM_CLIENT) {
 385                  skip = TRUE;
 386              }
 387          }
 388   
 389          while (sc.dlen > 0) {
 390              bcount = (sc.dlen < FLT_BUF_SIZE) ? sc.dlen : FLT_BUF_SIZE;
 391              nchars = fread(buffer, 1, bcount, data_out_file);
 392              if (nchars == 0)
 393                  break;
 394              /* XXX - if we don't get "bcount" bytes, is that an error? */
 395              sc.dlen -= (guint32) nchars;
 396   
 397              if (!skip) {
 398                      frs_return = follow_show(follow_info, print_line, buffer,
 399                                               nchars, is_server, arg, global_pos,
 400                                               &server_packet_count,
 401[+]                                              &client_packet_count);
expand/collapse

follow_show

(/home/sate/Testcases/c/cve/wireshark-1.2.0/gtk/follow_stream.c)expand/collapse
Show more  
 977  follow_show(follow_info_t *follow_info,
 978              gboolean (*print_line)(char *, size_t, gboolean, void *),
 979              char *buffer, size_t nchars, gboolean is_server, void *arg,
 980              guint32 *global_pos, guint32 *server_packet_count,
 981              guint32 *client_packet_count)
 982  {
 983          gchar initbuf[256];
 984          guint32 current_pos;
 985          static const gchar hexchars[16] = "0123456789abcdef";
 986   
 987          switch (follow_info->show_type) {
 988   
 989          case SHOW_EBCDIC:
 990                  /* If our native arch is ASCII, call: */
 991                  EBCDIC_to_ASCII(buffer, (guint) nchars);
 992                  if (!(*print_line) (buffer, nchars, is_server, arg))
 993                          return FRS_PRINT_ERROR;
 994                  break;
 995   
 996          case SHOW_ASCII:
 997                  /* If our native arch is EBCDIC, call:
 998                   * ASCII_TO_EBCDIC(buffer, nchars);
 999                   */
 1000                  if (!(*print_line) (buffer, nchars, is_server, arg))
 1001                          return FRS_PRINT_ERROR;
 1002                  break;
 1003   
 1004          case SHOW_RAW:
 1005                  /* Don't translate, no matter what the native arch
 1006                   * is.
 1007                   */
 1008                  if (!(*print_line) (buffer, nchars, is_server, arg))
 1009                          return FRS_PRINT_ERROR;
 1010                  break;
 1011   
 1012          case SHOW_HEXDUMP:
 1013                  current_pos = 0;
 1014                  while (current_pos < nchars) {
 1015                          gchar hexbuf[256];
 1016                          int i;
 1017                          gchar *cur = hexbuf, *ascii_start;
 1018   
 1019                          /* is_server indentation : put 4 spaces at the 
 1020                           * beginning of the string */
 1021                          /* XXX - We might want to prepend each line with "C" or "S" instead. */
 1022                          if (is_server && follow_info->show_stream == BOTH_HOSTS) {
 1023                                  memset(cur, ' ', 4);
 1024                                  cur += 4;
 1025                          }
 1026                          cur += g_snprintf(cur, 20, "%08X  ", *global_pos);
 1027                          /* 49 is space consumed by hex chars */
 1028                          ascii_start = cur + 49;
 1029                          for (i = 0; i < 16 && current_pos + i < nchars; i++) {
 1030                                  *cur++ =
 1031                                          hexchars[(buffer[current_pos + i] & 0xf0) >> 4];
 1032                                  *cur++ =
 1033                                          hexchars[buffer[current_pos + i] & 0x0f];
 1034                                  *cur++ = ' ';
 1035                                  if (i == 7)
 1036                                          *cur++ = ' ';
 1037                          }
 1038                          /* Fill it up if column isn't complete */
 1039                          while (cur < ascii_start)
 1040                                  *cur++ = ' ';
 1041   
 1042                          /* Now dump bytes as text */
 1043                          for (i = 0; i < 16 && current_pos + i < nchars; i++) {
 1044                                  *cur++ =
 1045                                          (isprint((guchar)buffer[current_pos + i]) ?
Show more  
 402                      if(frs_return == FRS_PRINT_ERROR) {
Show more  




Change Warning 4084.30358 : Cast Alters Value

Priority:
State:
Finding:
Owner:
Note: