Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix buffer overflow gripes in RHEL-8 build #861

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 9 additions & 16 deletions cppcache/integration-test/testExpiration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,33 +54,26 @@ void startDSandCreateCache(std::shared_ptr<Cache> &cache) {

void doNPuts(std::shared_ptr<Region> &rptr, int n) {
std::shared_ptr<CacheableString> value;
char buf[16];
memset(buf, 'A', 15);
buf[15] = '\0';
memcpy(buf, "Value - ", 8);
value = CacheableString::create(buf);
value = CacheableString::create("Value - AAAAAAA");
ASSERT(value != nullptr, "Failed to create value.");

for (int i = 0; i < n; i++) {
sprintf(buf, "KeyA - %d", i + 1);
auto key = CacheableKey::create(buf);
LOGINFO("Putting key %s value %s in region %s", buf,
auto keyStr = std::string("KeyA - ") + std::to_string(i + 1);
auto key = CacheableKey::create(keyStr);
LOGINFO("Putting key %s value %s in region %s", keyStr.c_str(),
value->toString().c_str(), rptr->getFullPath().c_str());
rptr->put(key, value);
}
}

std::shared_ptr<CacheableKey> do1Put(std::shared_ptr<Region> &rptr) {
std::shared_ptr<CacheableString> value;
char buf[16];
memset(buf, 'A', 15);
buf[15] = '\0';
memcpy(buf, "Value - ", 8);
value = CacheableString::create(buf);
value = CacheableString::create("Value - AAAAAAA");
ASSERT(value != nullptr, "Failed to create value.");

sprintf(buf, "KeyA - %d", 0 + 1);
auto key = CacheableKey::create(buf);
LOGINFO("Putting key %s value %s in region %s", buf,
std::string keyStr("KeyA - 1");
auto key = CacheableKey::create(keyStr);
LOGINFO("Putting key %s value %s in region %s", keyStr.c_str(),
value->toString().c_str(), rptr->getFullPath().c_str());
rptr->put(key, value);
return key;
Expand Down
10 changes: 3 additions & 7 deletions cppcache/integration-test/testThinClientLRUExpiration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,19 +172,15 @@ void createRegion(const char *name, bool ackMode,

void doRgnOperations(const char *name, int n, int rgnOpt = 0) {
std::shared_ptr<CacheableString> value;
char buf[16];
if (rgnOpt == 0) {
memset(buf, 'A', 15);
buf[15] = '\0';
memcpy(buf, "Value - ", 8);
value = CacheableString::create(buf);
value = CacheableString::create("Value - AAAAAAA");
ASSERT(value != nullptr, "Failed to create value.");
}
auto rptr = getHelper()->getRegion(name);
ASSERT(rptr != nullptr, "Region not found.");
for (int i = 0; i < n; i++) {
sprintf(buf, "KeyA - %d", i + 1);
auto key = CacheableKey::create(buf);
auto keyStr = std::string("KeyA - ") + std::to_string(i + 1);
auto key = CacheableKey::create(keyStr);
switch (rgnOpt) {
case 0:
rptr->put(key, value);
Expand Down