Open
Description
Affected rules
- cpp/cert/container-access-without-range-check-cert
Description
The rule warns about the vector container which is resized after delectation.
Access of container of type Payload does not ensure that the index is smaller than the bounds.
Example
#include <iostream>
#include <string>
#include <vector>
#include <filesystem>
using namespace std;
namespace fs = std::filesystem;
int main() {
typedef vector<uint8_t> Payload;
wstring file(L"This is a wstring");
uint64_t attributes;
Payload serialized_data; serialized_data.resize(file.size() * sizeof(wchar_t) + sizeof(attributes));
*(uint64_t*)&serialized_data.front() = attributes;
/*
* Append the path.
*/
file.copy((wchar_t*)&serialized_data[sizeof(attributes)], file.size());
return 0;
}
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Triaged