Versions Compared

Key

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

...

Wiki Markup
In this non-compliant code example, the call to {{strpcy()}} has been replaced with a call to {{strcpy_s()}}.  See \[[STR00-A. Use TR 24731 for remediation of existing string manipulation code]] for more information on using {{strcpy_s()}}.

Code Block
bgColor#FFCCCC
char msg[100];
/* ... */
void error_message(char *error_msg) {
  char msg[80];
  /* ... */

  /* error_msg is assumed to reference a NTBS of length 99 or less */
  errno_t e = strcpy_s(msg, sizeof(msg), error_msg);
  if (e != 0) {
     /* handle strcpy_s() error */
  }
}

...