Skip to content

Commit df36ae6

Browse files
committed
fixed GH pocoproject#958: Bug while reading X509Certificate subjectName
1 parent 92e2a19 commit df36ae6

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

Crypto/src/X509Certificate.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,10 @@ std::string X509Certificate::issuerName(NID nid) const
205205
if (X509_NAME* issuer = X509_get_issuer_name(_pCert))
206206
{
207207
char buffer[NAME_BUFFER_SIZE];
208-
X509_NAME_get_text_by_NID(issuer, nid, buffer, sizeof(buffer));
209-
return std::string(buffer);
208+
if (X509_NAME_get_text_by_NID(issuer, nid, buffer, sizeof(buffer)) >= 0)
209+
return std::string(buffer);
210210
}
211-
else return std::string();
211+
return std::string();
212212
}
213213

214214

@@ -217,10 +217,10 @@ std::string X509Certificate::subjectName(NID nid) const
217217
if (X509_NAME* subj = X509_get_subject_name(_pCert))
218218
{
219219
char buffer[NAME_BUFFER_SIZE];
220-
X509_NAME_get_text_by_NID(subj, nid, buffer, sizeof(buffer));
221-
return std::string(buffer);
220+
if (X509_NAME_get_text_by_NID(subj, nid, buffer, sizeof(buffer)) >= 0)
221+
return std::string(buffer);
222222
}
223-
else return std::string();
223+
return std::string();
224224
}
225225

226226

0 commit comments

Comments
 (0)