...
In the following compliant solution a union is used to impose unsigned long's alignment on the array B
Code Block | ||
---|---|---|
| ||
struct A{ unsigned long i; }; union AlignedUnion{ unsigned char B[sizeof(A)]; private: unsigned long _align_; }algn; int main() { A *a = new(&algn.B[0]) A; unsigned long val = 0xaabbccdd; a->i = val; return (0); } |
Risk Assessment
Rule | Severity | Likelihood | Remediation Cost | Priority | Level |
MEM45-CPP | low | probable | 1 | P2 | L3 |
Related Related Vulnerabilities
Search for vulnerabilities resulting from the violation of this rule on the CERT website.
Bibliography
Wiki Markup |
---|
\[[ISO/IEC 14882-2003|https://www.securecoding.cert.org/display/cplusplus/AA.+Bibliography#AA.Bibliography-ISO%2FIEC148822003]\] 3.7.4.1 |