Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

In this compliant solution, the size of buf, INTBUFSIZE, is added directly to buf and used as an upper bound. The integer literal INTBUFSIZE is scaled to the size of an integer, and the upper bound of buf is checked correctly.

...

Pointer casting and pointer type changes [HFC]
Pointer arithmetic [RVG
CERT C++ Secure Coding StandardEXP08-CPP. Ensure pointer arithmetic is used correctly
ISO/IEC TR 24772Pointer casting and pointer type changes [HFC]
Pointer arithmetic [RVG]
ISO/IEC TS 17961(Draft) Adding or subtracting a byte count to an element pointer [cntradd]ISO/IEC TR 24772]
MISRA-CRule 17.1 (required): Pointer arithmetic shall only be applied to pointers that address an array or array element
Rule 17.2 (required): Pointer subtraction shall only be applied to pointers that address elements of the same array
Rule 17.3 (required): >, >=, <, <= shall not be applied to pointer types except where they point to the same array
Rule 17.4 (required): Array indexing shall be the only allowed form of pointer arithmetic
MITRE CWECWE-468, Incorrect pointer scaling

...