HDFS-15910. Improve security with explicit_bzero (#2793)

This commit is contained in:
Gautham B A 2021-03-23 22:28:19 +05:30 committed by GitHub
parent 9c2a712597
commit 714427c414
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 3 deletions

View File

@ -1395,7 +1395,7 @@ int hdfsGetBlockLocations(hdfsFS fs, const char *path, struct hdfsBlockLocations
hdfsBlockLocations *locations = new struct hdfsBlockLocations(); hdfsBlockLocations *locations = new struct hdfsBlockLocations();
(*locations_out) = locations; (*locations_out) = locations;
bzero(locations, sizeof(*locations)); explicit_bzero(locations, sizeof(*locations));
locations->fileLength = ppLocations->getFileLength(); locations->fileLength = ppLocations->getFileLength();
locations->isLastBlockComplete = ppLocations->isLastBlockComplete(); locations->isLastBlockComplete = ppLocations->isLastBlockComplete();
locations->isUnderConstruction = ppLocations->isUnderConstruction(); locations->isUnderConstruction = ppLocations->isUnderConstruction();

View File

@ -475,7 +475,7 @@ TEST_F(HdfsExtTest, TestReadStats) {
hdfsFile file = hdfsOpenFile(fs, path.c_str(), O_WRONLY, 0, 0, 0); hdfsFile file = hdfsOpenFile(fs, path.c_str(), O_WRONLY, 0, 0, 0);
EXPECT_NE(nullptr, file); EXPECT_NE(nullptr, file);
void * buf = malloc(size); void * buf = malloc(size);
bzero(buf, size); explicit_bzero(buf, size);
EXPECT_EQ(size, hdfsWrite(fs, file, buf, size)); EXPECT_EQ(size, hdfsWrite(fs, file, buf, size));
free(buf); free(buf);
EXPECT_EQ(0, hdfsCloseFile(fs, file)); EXPECT_EQ(0, hdfsCloseFile(fs, file));

View File

@ -92,7 +92,7 @@ public:
hdfsFile file = hdfsOpenFile(*this, path.c_str(), O_WRONLY, 0, 0, 0); hdfsFile file = hdfsOpenFile(*this, path.c_str(), O_WRONLY, 0, 0, 0);
EXPECT_NE(nullptr, file); EXPECT_NE(nullptr, file);
void * buf = malloc(size); void * buf = malloc(size);
bzero(buf, size); explicit_bzero(buf, size);
EXPECT_EQ(1024, hdfsWrite(*this, file, buf, size)); EXPECT_EQ(1024, hdfsWrite(*this, file, buf, size));
EXPECT_EQ(0, hdfsCloseFile(*this, file)); EXPECT_EQ(0, hdfsCloseFile(*this, file));
free(buf); free(buf);