Changeset 315c9b89 in rtems


Ignore:
Timestamp:
Mar 15, 2011, 3:05:29 PM (9 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.11, master
Children:
a47dd1c
Parents:
d252351
Message:

2011-03-15 Joel Sherrill <joel.sherrill@…>

  • libfs/src/dosfs/msdos_format.c: Address Coverity issue 183 which was where an expression evaluated to a constant and issue 185 which was a potential (although unlikely in expected usage) time-of-check, time-of-use race condition.
Location:
cpukit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • cpukit/ChangeLog

    rd252351 r315c9b89  
     12011-03-15      Joel Sherrill <joel.sherrill@oarcorp.com>
     2
     3        * libfs/src/dosfs/msdos_format.c: Address Coverity issue 183 which was
     4        where an expression evaluated to a constant and issue 185 which was a
     5        potential (although unlikely in expected usage) time-of-check,
     6        time-of-use race condition.
     7
    182011-03-15      Joel Sherrill <joel.sherrill@oarcorp.com>
    29
  • cpukit/libfs/src/dosfs/msdos_format.c

    rd252351 r315c9b89  
    897897  msdos_format_param_t fmt_params;
    898898
     899  /*
     900   * open device for writing
     901   */
     902  msdos_format_printf (rqdata, MSDOS_FMT_INFO_LEVEL_DETAIL, "open device\n");
     903  fd = open(devname, O_RDWR);
     904  if (fd == -1) {
     905    ret_val= -1;
     906  }
     907
     908  /*
     909   * sanity check on device
     910   */
     911  msdos_format_printf (rqdata, MSDOS_FMT_INFO_LEVEL_DETAIL,
     912                       "stat check: %s\n", devname);
     913  if (ret_val == 0) {
     914    rc = fstat(fd, &stat_buf);
     915    ret_val = rc;
     916  }
     917
    899918  msdos_format_printf (rqdata, MSDOS_FMT_INFO_LEVEL_INFO,
    900919                       "formating: %s\n", devname);
    901   /*
    902    * sanity check on device
    903    */
    904   msdos_format_printf (rqdata, MSDOS_FMT_INFO_LEVEL_DETAIL,
    905                        "stat check: %s\n", devname);
    906   if (ret_val == 0) {
    907     rc = stat(devname, &stat_buf);
    908     ret_val = rc;
    909   }
    910 
    911920  /* rtems feature: no block devices, all are character devices */
    912   if ((ret_val == 0) &&
    913       (!S_ISBLK(stat_buf.st_mode))) {
     921  if ((ret_val == 0) && (!S_ISBLK(stat_buf.st_mode))) {
    914922    errno = ENOTTY;
    915923    ret_val = -1;
     
    922930      errno = ENOTTY;
    923931      ret_val = -1;
    924     }
    925   }
    926 
    927   /*
    928    * open device for writing
    929    */
    930   if (ret_val == 0) {
    931     msdos_format_printf (rqdata, MSDOS_FMT_INFO_LEVEL_DETAIL,
    932                          "open device\n");
    933     fd = open(devname, O_RDWR);
    934     if (fd == -1)
    935     {
    936       ret_val= -1;
    937932    }
    938933  }
     
    958953       0xe5);
    959954  }
     955
    960956  /*
    961957   * create master boot record
     
    10811077    case FAT_FAT16:
    10821078      /* FAT entry 0: 0xff00|media_type */
    1083       FAT_SET_VAL16(tmp_sec,0,0xff00|fmt_params.media_code);
     1079      FAT_SET_VAL8(tmp_sec,0,fmt_params.media_code);
     1080      FAT_SET_VAL8(tmp_sec,1,0xff);
    10841081      /* FAT entry 1: EOC */
    10851082      FAT_SET_VAL16(tmp_sec,2,FAT_FAT16_EOC);
Note: See TracChangeset for help on using the changeset viewer.