Skip to content

Commit 16058ce

Browse files
author
Lealem Amedie
committed
Address review comments
1 parent 5ba5793 commit 16058ce

2 files changed

Lines changed: 34 additions & 26 deletions

File tree

src/ssl.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29370,9 +29370,10 @@ void* wolfSSL_GetHKDFExtractCtx(WOLFSSL* ssl)
2937029370
#endif /* OPENSSL_EXTRA || OPENSSL_EXTRA_X509_SMALL */
2937129371

2937229372
#if defined(OPENSSL_ALL)
29373-
/* Returns the oid buffer from the short name or long name of an ASN1_object
29374-
* and NULL on failure */
29375-
const byte* wolfSSL_OBJ_txt2oidBuf(char* buf, word32* inOutSz, word32 oidType)
29373+
/* Returns the oid buffer from the short name or long name of an ASN1_object
29374+
* and NULL on failure */
29375+
const byte* wolfSSL_OBJ_txt2oidBuf(char* buf, word32* inOutSz,
29376+
word32 oidType)
2937629377
{
2937729378
word32 oid;
2937829379
int nid;

wolfcrypt/src/asn.c

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12353,16 +12353,16 @@ static int GenerateDNSEntryIPString(DNS_entry* entry, void* heap)
1235312353
*/
1235412354
static int GenerateDNSEntryRIDString(DNS_entry* entry, void* heap)
1235512355
{
12356-
int i, j, ret = 0;
12357-
int nameSz;
12358-
int tmpSize = MAX_OID_SZ;
12359-
int endChar = 0;
12360-
int nid = 0;
12361-
word32 oid = 0;
12362-
word32 idx = 0;
12356+
int i, j, ret = 0;
12357+
int nameSz = 0;
12358+
int numerical = 0;
12359+
int nid = 0;
12360+
int tmpSize = MAX_OID_SZ;
12361+
word32 oid = 0;
12362+
word32 idx = 0;
1236312363
word16 tmpName[MAX_OID_SZ];
12364-
char finalName[MAX_OID_SZ];
12365-
char* rid;
12364+
char oidName[MAX_OID_SZ];
12365+
char* finalName;
1236612366

1236712367
if (entry == NULL || entry->type != ASN_RID_TYPE) {
1236812368
return BAD_FUNC_ARG;
@@ -12372,30 +12372,30 @@ static int GenerateDNSEntryRIDString(DNS_entry* entry, void* heap)
1237212372
return BAD_FUNC_ARG;
1237312373
}
1237412374

12375-
XMEMSET(&finalName, 0, MAX_OID_SZ);
12376-
rid = entry->name;
12375+
XMEMSET(&oidName, 0, MAX_OID_SZ);
1237712376

12378-
ret = GetOID((const byte*)rid, &idx, &oid, oidIgnoreType, entry->len);
12377+
ret = GetOID((const byte*)entry->name, &idx, &oid, oidIgnoreType,
12378+
entry->len);
1237912379

1238012380
if (ret == 0 && (nid = oid2nid(oid, oidCsrAttrType)) > 0) {
12381-
rid = (char*)wolfSSL_OBJ_nid2ln(nid);
12382-
XMEMCPY(finalName, rid, XSTRLEN((const char*)rid));
12381+
/* OID has known string value */
12382+
finalName = (char*)wolfSSL_OBJ_nid2ln(nid);
1238312383
}
1238412384
else {
1238512385
/* Decode OBJECT_ID into dotted form array. */
12386-
ret = DecodeObjectId((const byte*)(rid),(word32)entry->len, tmpName,
12387-
(word32*)&tmpSize);
12386+
ret = DecodeObjectId((const byte*)(entry->name),(word32)entry->len,
12387+
tmpName, (word32*)&tmpSize);
1238812388

12389+
numerical = 1;
1238912390
if (ret == 0) {
12390-
endChar = 1;
1239112391
j = 0;
1239212392
/* Append each number of dotted form. */
1239312393
for (i = 0; i < tmpSize; i++) {
12394-
ret = XSNPRINTF(finalName + j, MAX_OID_SZ, "%d", tmpName[i]);
12394+
ret = XSNPRINTF(oidName + j, MAX_OID_SZ, "%d", tmpName[i]);
1239512395
if (ret >= 0) {
1239612396
j += ret;
1239712397
if (i < tmpSize - 1) {
12398-
finalName[j] = '.';
12398+
oidName[j] = '.';
1239912399
j++;
1240012400
}
1240112401
}
@@ -12404,19 +12404,26 @@ static int GenerateDNSEntryRIDString(DNS_entry* entry, void* heap)
1240412404
}
1240512405
}
1240612406
ret = 0;
12407+
finalName = oidName;
1240712408
}
1240812409
}
1240912410

1241012411
if (ret == 0) {
1241112412
nameSz = (int)XSTRLEN((const char*)finalName);
12412-
entry->ridString = (char*)XMALLOC(nameSz + endChar, heap, DYNAMIC_TYPE_ALTNAME);
12413+
12414+
entry->ridString = (char*)XMALLOC(nameSz + numerical, heap,
12415+
DYNAMIC_TYPE_ALTNAME);
12416+
1241312417
if (entry->ridString == NULL) {
1241412418
ret = MEMORY_E;
1241512419
}
1241612420

12417-
XMEMCPY(entry->ridString, finalName, nameSz);
12418-
if (endChar)
12419-
entry->ridString[nameSz] = '\0';
12421+
if (ret == 0) {
12422+
XMEMCPY(entry->ridString, finalName, nameSz);
12423+
if (numerical) {
12424+
entry->ridString[nameSz] = '\0';
12425+
}
12426+
}
1242012427
}
1242112428

1242212429
return ret;

0 commit comments

Comments
 (0)