...
Code Block | ||||
---|---|---|---|---|
| ||||
#include <stddef.h> #include <stdio.h> #define BUFFER_SIZE 1024 void f(FILE *file) { enum { BUFFER_SIZE = 1024 }; wchar_t wbuf[BUFFER_SIZE]; const size_t size = sizeof(*wbuf); const size_t nitems = sizeof(wbuf); size_t nread; nread = fread(wbuf, size, nitems, file); } |
...
Code Block | ||||
---|---|---|---|---|
| ||||
#include <stddef.h> #include <stdio.h> #define BUFFER_SIZE 1024 void f(FILE *file) { enum { BUFFER_SIZE = 1024 }; wchar_t wbuf[BUFFER_SIZE]; const size_t size = sizeof(*wbuf); const size_t nitems = sizeof(wbuf) / size; size_t nread; nread = fread(wbuf, size, nitems, file); } |
...
C Secure Coding Standard | API00-C. Functions should validate their parameters ARR01-C. Do not apply the sizeof operator to a pointer when taking the size of an array INT30-C. Ensure that unsigned integer operations do not wrap |
ISO/IEC TS 17961 | Forming invalid pointers by library functions [libptr] |
ISO/IEC TR 24772:2013 | Buffer Boundary Violation (Buffer Overflow) [HCB] |
MITRE CWE
| CWE-119, Failure to constrain operations within the bounds of an allocated memory buffer |
...