...
| Code Block | ||||
|---|---|---|---|---|
| ||||
#include <string.h>
void func(const char *src) {
/* Validate the source string; calculate size */
char *dest;
/* malloc destination string */
memcpy(dest, src,
#ifdef PLATFORM1
12
#else
24
#endif
);
/* ... */
);
|
Compliant Solution
...
| Code Block | ||||
|---|---|---|---|---|
| ||||
#include <string.h>
void func(const char *src) {
/* Validate the source string; calculate size */
char *dest;
/* malloc destination string */
#ifdef PLATFORM1
memcpy(dest, src, 12);
#else
memcpy(dest, src, 24);
#endif
/* ... */
} |
Risk Assessment
Improper use of macros may result in Using preprocessor directives inside macro arguments is undefined behavior.
Rule | Severity | Likelihood | Remediation Cost | Priority | Level |
|---|---|---|---|---|---|
PRE32-C | Low | Unlikely | Medium | P2 | L3 |
...