Address review comments

This commit is contained in:
Lealem Amedie
2023-07-19 12:01:01 -06:00
parent 5ba579397d
commit 16058ce168
2 changed files with 34 additions and 26 deletions

View File

@@ -29372,7 +29372,8 @@ void* wolfSSL_GetHKDFExtractCtx(WOLFSSL* ssl)
#if defined(OPENSSL_ALL) #if defined(OPENSSL_ALL)
/* Returns the oid buffer from the short name or long name of an ASN1_object /* Returns the oid buffer from the short name or long name of an ASN1_object
* and NULL on failure */ * and NULL on failure */
const byte* wolfSSL_OBJ_txt2oidBuf(char* buf, word32* inOutSz, word32 oidType) const byte* wolfSSL_OBJ_txt2oidBuf(char* buf, word32* inOutSz,
word32 oidType)
{ {
word32 oid; word32 oid;
int nid; int nid;

View File

@@ -12354,15 +12354,15 @@ static int GenerateDNSEntryIPString(DNS_entry* entry, void* heap)
static int GenerateDNSEntryRIDString(DNS_entry* entry, void* heap) static int GenerateDNSEntryRIDString(DNS_entry* entry, void* heap)
{ {
int i, j, ret = 0; int i, j, ret = 0;
int nameSz; int nameSz = 0;
int tmpSize = MAX_OID_SZ; int numerical = 0;
int endChar = 0;
int nid = 0; int nid = 0;
int tmpSize = MAX_OID_SZ;
word32 oid = 0; word32 oid = 0;
word32 idx = 0; word32 idx = 0;
word16 tmpName[MAX_OID_SZ]; word16 tmpName[MAX_OID_SZ];
char finalName[MAX_OID_SZ]; char oidName[MAX_OID_SZ];
char* rid; char* finalName;
if (entry == NULL || entry->type != ASN_RID_TYPE) { if (entry == NULL || entry->type != ASN_RID_TYPE) {
return BAD_FUNC_ARG; return BAD_FUNC_ARG;
@@ -12372,30 +12372,30 @@ static int GenerateDNSEntryRIDString(DNS_entry* entry, void* heap)
return BAD_FUNC_ARG; return BAD_FUNC_ARG;
} }
XMEMSET(&finalName, 0, MAX_OID_SZ); XMEMSET(&oidName, 0, MAX_OID_SZ);
rid = entry->name;
ret = GetOID((const byte*)rid, &idx, &oid, oidIgnoreType, entry->len); ret = GetOID((const byte*)entry->name, &idx, &oid, oidIgnoreType,
entry->len);
if (ret == 0 && (nid = oid2nid(oid, oidCsrAttrType)) > 0) { if (ret == 0 && (nid = oid2nid(oid, oidCsrAttrType)) > 0) {
rid = (char*)wolfSSL_OBJ_nid2ln(nid); /* OID has known string value */
XMEMCPY(finalName, rid, XSTRLEN((const char*)rid)); finalName = (char*)wolfSSL_OBJ_nid2ln(nid);
} }
else { else {
/* Decode OBJECT_ID into dotted form array. */ /* Decode OBJECT_ID into dotted form array. */
ret = DecodeObjectId((const byte*)(rid),(word32)entry->len, tmpName, ret = DecodeObjectId((const byte*)(entry->name),(word32)entry->len,
(word32*)&tmpSize); tmpName, (word32*)&tmpSize);
numerical = 1;
if (ret == 0) { if (ret == 0) {
endChar = 1;
j = 0; j = 0;
/* Append each number of dotted form. */ /* Append each number of dotted form. */
for (i = 0; i < tmpSize; i++) { for (i = 0; i < tmpSize; i++) {
ret = XSNPRINTF(finalName + j, MAX_OID_SZ, "%d", tmpName[i]); ret = XSNPRINTF(oidName + j, MAX_OID_SZ, "%d", tmpName[i]);
if (ret >= 0) { if (ret >= 0) {
j += ret; j += ret;
if (i < tmpSize - 1) { if (i < tmpSize - 1) {
finalName[j] = '.'; oidName[j] = '.';
j++; j++;
} }
} }
@@ -12404,20 +12404,27 @@ static int GenerateDNSEntryRIDString(DNS_entry* entry, void* heap)
} }
} }
ret = 0; ret = 0;
finalName = oidName;
} }
} }
if (ret == 0) { if (ret == 0) {
nameSz = (int)XSTRLEN((const char*)finalName); nameSz = (int)XSTRLEN((const char*)finalName);
entry->ridString = (char*)XMALLOC(nameSz + endChar, heap, DYNAMIC_TYPE_ALTNAME);
entry->ridString = (char*)XMALLOC(nameSz + numerical, heap,
DYNAMIC_TYPE_ALTNAME);
if (entry->ridString == NULL) { if (entry->ridString == NULL) {
ret = MEMORY_E; ret = MEMORY_E;
} }
if (ret == 0) {
XMEMCPY(entry->ridString, finalName, nameSz); XMEMCPY(entry->ridString, finalName, nameSz);
if (endChar) if (numerical) {
entry->ridString[nameSz] = '\0'; entry->ridString[nameSz] = '\0';
} }
}
}
return ret; return ret;
} }