Revert #242 and improve security when sending files to client

This commit is contained in:
yuanyuanxiang
2025-12-28 14:39:52 +01:00
parent 2d274aab4d
commit 473af822cc
10 changed files with 111 additions and 40 deletions

View File

@@ -73,6 +73,22 @@ public:
{
return md5;
}
BYTE GetBYTE(int idx=0) const {
return idx >= len ? 0 : buf[idx];
}
LPBYTE GetBuffer(int idx=0) const {
return idx >= len ? 0 : buf + idx;
}
int GetBufferLength() const {
return len;
}
BOOL CopyBuffer(PVOID pDst, ULONG nLen, ULONG ulPos=0) {
if (len - ulPos < nLen) {
return FALSE;
}
memcpy(pDst, buf + ulPos, nLen);
return TRUE;
}
};
class CBuffer
@@ -98,7 +114,7 @@ public:
return WriteBuffer(buf.GetBuffer(), buf.GetBufferLen());
}
LPBYTE GetBuffer(ULONG ulPos=0);
Buffer GetMyBuffer(ULONG ulPos);
Buffer GetMyBuffer(ULONG ulPos=0);
BYTE GetBYTE(ULONG ulPos);
BOOL CopyBuffer(PVOID pDst, ULONG nLen, ULONG ulPos);
ULONG RemoveCompletedBuffer(ULONG ulLength);