Uploaded image for project: 'Embedded Software & Tools'
  1. Embedded Software & Tools
  2. EXT_EP-10178

sscanf float conversion should fail and return 0 when input string starts with E or e

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Medium Medium
    • Code Generation Tools
    • CODEGEN-8485
    • Hide
      ARM_5.2.5
      C7000_1.4.0.LTS
      C6000_8.2.0
      C6000_8.3.0
      MSP430_20.2.0.LTS
      ARP32_1.0.0
      ARM_18.12.0.LTS
      MSP430_18.12.0.LTS
      PRU_2.3.0
      ARM_20.2.0.LTS
      Show
      ARM_5.2.5 C7000_1.4.0.LTS C6000_8.2.0 C6000_8.3.0 MSP430_20.2.0.LTS ARP32_1.0.0 ARM_18.12.0.LTS MSP430_18.12.0.LTS PRU_2.3.0 ARM_20.2.0.LTS
    • Hide
      ARM_18.12.8.LTS*
      MSP430_18.12.8.LTS*
      MSP430_20.2.5.LTS*
      C6000_8.3.9*
      ARM_20.2.5.LTS*
      C2000_20.2.5.LTS*
      PRU_2.3.4*
      C7000_1.4.2.LTS*
      C2000_18.12.8.LTS*
      Show
      ARM_18.12.8.LTS* MSP430_18.12.8.LTS* MSP430_20.2.5.LTS* C6000_8.3.9* ARM_20.2.5.LTS* C2000_20.2.5.LTS* PRU_2.3.4* C7000_1.4.2.LTS* C2000_18.12.8.LTS*
    • default

      When sscanf("%f") is faced with an input that looks like "EP", the conversion is supposed to fail and sscanf is supposed to return 0, consuming no characters. However, the TI sscanf implementation mistakenly consumes the E and returns 1, indicating a successful conversion. sscanf mistakenly accepts a variety of invalid float input items. This affects all members of the *scanf family.

      #include <stdio.h>
      
      int main()
      {
          float f;
          int rv = sscanf("EP", "%f", &f);
          printf("rv == %d, expected 0\n", rv);
      }
      

            syncuser TI User
            syncuser TI User
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: