Versions Compared

Key

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

Several common Common mistakes in creating format strings are listed belowinclude:

  • using invalid conversion specifiers
  • using a length modifier on an incorrect specifier
  • mismatching the argument and conversion specifier type mismatch
  • using invalid character classes

...

Code Block
d, i, o, u, x, X, a, A, e, E, f, F, g, G

Also, character Character class ranges must also be properly specified, with a hyphen in between two printable characters. The two following lines are both properly specified. The first accepts any character from a-z, inclusive, while the second accepts anything that is not a-z, inclusive.

Code Block
[a-z]
[^a-z]

Having an argument Mismatches between arguments and conversion specifier mismatch specifiers may result in undefined behavior.

...

Risk Assessment

In most cases, the undefined behavior referred to above incorrectly specified format strings will result in abnormal program termination.

...