Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- typedef struct _DCMOTSTATUS
- {
- unsigned short wChannel; // Channel ident.
- unsigned int lPosition; // Position in encoder counts.
- unsigned short wVelocity; // Velocity in encoder counts/sec.
- unsigned short wReserved; // Controller specific use
- unsigned int dwStatusBits; // Status bits (see #defines below).
- } DCMOTSTATUS;
- int MotorStage::ParseStatus(const unsigned char* buf, int bufLen,
- DCMOTSTATUS& stat)
- {
- ....
- memcpy(&stat.lPosition, buf + bufPtr, sizeof(long)); //<<<(1)
- bufPtr += sizeof(long);
- memcpy(&stat.wVelocity, buf + bufPtr, sizeof(unsigned short));
- bufPtr += sizeof(unsigned short);
- memcpy(&stat.wReserved, buf + bufPtr, sizeof(unsigned short));
- bufPtr += sizeof(unsigned short);
- memcpy(&stat.dwStatusBits,
- buf + bufPtr, sizeof(unsigned long)); //<<<(2)
- return DEVICE_OK;
- }
- (1) - Not critical. (2) - Critical.
- This suspicious code was found in Micro-Manager project by PVS-Studio static code analyzer.
- Warning message is:
- V512 A call of the 'memcpy' function will lead to overflow of the buffer '& stat.lPosition'. MotorStage.cpp 247
- PVS-Studio is a static analyzer for detecting bugs in the source code of applications written in C, C++, C++11, C++/CX. Site: http://www.viva64.com/en/pvs-studio/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement