![]() |
![]() |
2846 | ![]() |
||||
![]() | |||||||
| Arrays | |||||||
A definite anomaly has been detected. Certain standard library functions specify a maximum number (M) of characters to be written to a char array (A).
| function | A parameter number | M parameter number |
|---|---|---|
| asctime_s | 1 | 2 |
| ctime_s | 1 | 2 |
| snprintf | 1 | 2 |
| snprintf_s | 1 | 2 |
| strcpy_s | 1 | 2 |
| strncat | 1 | 3 |
| strncat_s | 1 | 2 |
| strncat_s | 1 | 4 |
| strncat_s | 3 | 4 |
| strncpy | 1 | 3 |
| strncpy_s | 1 | 4 |
/*PRQA S 1-9999 ++*/
/*PRQA S 2846 --*/
#include <string.h>
extern char a[10];
extern char b[11];
void foo (int m)
{
if (m > sizeof (a))
{
strncpy (a, b, m); /* 2846 */
}
}
MISRA-C:2004 Rules applicable to message 2846:
| Rule 21.1 (Required) | Minimisation of run-time failures shall be ensured by the use of at least one of (a) static analysis tools/techniques; (b) dynamic analysis tools/techniques; (c) explicit coding of checks to handle run-time faults |
See also:
![]() | ||
| QA·C Source Code Analyser 8.1
MISRA-C:2004 Compliance Module 3.2 © 2012 Programming Research. www.programmingresearch.com | Personality Groups | Glossary | Message Index | MISRA-C:2004 Rule Index | Contents |