Skip to content
OpenAdvisories

Weakness (CWE)

CWE-196: Unsigned to Signed Conversion Error

Variant Draft

The product uses an unsigned primitive and performs a cast to a signed primitive, which can produce an unexpected value if the value of the unsigned primitive can not be represented using a signed primitive.

How to prevent it (3 mitigations)
  1. Requirements

    Choose a language which is not subject to these casting flaws.

  2. Architecture and Design

    Design object accessor functions to implicitly check values for valid sizes. Ensure that all functions which will be used as a size are checked previous to use as a size. If the language permits, throw exceptions rather than using in-band errors.

  3. Implementation

    Error check the return values of all functions. Be aware of implicit casts made, and use unsigned variables for sizes if at all possible.

Source: MITRE CWE-196

3 results · Clear filters · Feed

  • Critical 9.1

    Imager versions before 1.036 for Perl exit the process reading a TGA with a colour map length of 32768 or more in tga_palette_read

    Imager versions before 1.036 for Perl exit the process reading a TGA with a colour map length of 32768 or more in tga_palette_read. The reader unpacks the two-byte colour map length into a signed short, so a length of 32768 or more becomes negative. tga_palet…

  • Critical 9.8

    Imager versions before 1.033 for Perl treat unsigned EXIF IFD entry counts as signed

    Imager versions before 1.033 for Perl treat unsigned EXIF IFD entry counts as signed. Imager mishandled large EXIF IFD entry count values, treating them as negative numbers. This could lead to an attempt to allocate a block nearly the size of the address spac…

  • Critical 9.1

    Incorrect Conversion between Numeric Types in Besu Ethereum Client

    Besu is a Java-based Ethereum client. In versions newer than 22.1.3 and prior to 22.7.1, Besu is subject to an Incorrect Conversion between Numeric Types. An error in 32 bit signed and unsigned types in the calculation of available gas in the CALL operations …