Versions Compared

Key

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

...

This definition means that, when allocating storage, only the first member, num, is considered. Consequently, the result of accessing the member data of a variable of type struct flexArrayStruct is undefined. Guideline DCL38-C. Use the correct syntax when declaring flexible array members describes the correct way to declare a struct with a flexible array member.

...

Wiki Markup
The {{data\[\]}} member of {{flexStruct}} can now be accessed as described in C99, Section 6.7.2.1, paragraph 16.

...

The problem with this noncompliant code example is that, when the structure is copied, the size of the flexible array member is not considered and only the first member of the structure, num, is copied.

...

Flexible array structs should not be

  • declared on the stack, ; they should be on the heap.
  • copied via assignment, ; they should be copied using memcpy() or a similar function.
  • passed as raw arguments to functions, ; a pointer should be passed to flexArrayStruct intead.

Tool

Version

Checker

Description

Section

ROSE

 

 

Section

can detect all of these

...

Related Vulnerabilities

Search for vulnerabilities resulting from the violation of this rule on the CERT website.

...