Skip to content
Open
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
12 changes: 8 additions & 4 deletions folly/ssl/OpenSSLCertUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,16 @@ std::string getExtOid(X509_EXTENSION* extension) {
std::string ret(buf_size, '\0');
auto length = OBJ_obj2txt(ret.data(), ret.size(), object, 1);

if (length > buf_size) {
if (length < 0) {
return {};
}

if (length >= buf_size) {
// Reserve one byte for the terminating zero
ret.resize(length, '\0');
ret.resize(static_cast<size_t>(length) + 1, '\0');
OBJ_obj2txt(ret.data(), ret.size(), object, 1);
}
ret.resize(length);
ret.resize(static_cast<size_t>(length));
return ret;
}

Expand Down Expand Up @@ -440,4 +444,4 @@ X509StoreUniquePtr OpenSSLCertUtils::readStoreFromBuffer(ByteRange certRange) {
return store;
}
} // namespace ssl
} // namespace folly
} // namespace folly