You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 8 Next »

Variable length arrays (VLA) are basically the same as traditional C arrays, the major difference being they are declared with a size that is not a constant integer expression. A variable length array can be declared as follows:

char vla[s];

The above statement is evaluated at runtime allocating storage for s characters on the stack. If a size argument supplied to VLAs is not a positive integer value of reasonable size, then the program may behave in an unexpected way. An attacker may be able to leverage this behavior to overwrite critical program data (Feline 1). The programmer must ensure that size arguments to VLAs are valid and have not been corrupted as the result of an exceptional integer condition.

  • No labels