Skip to content

Commit 7592559

Browse files
rename argument, fix warnings on casts
1 parent ed4b87e commit 7592559

2 files changed

Lines changed: 16 additions & 15 deletions

File tree

wolfcrypt/src/asn.c

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3465,20 +3465,21 @@ word32 SetBitString(word32 len, byte unusedBits, byte* output)
34653465

34663466
/* sets the terminating 0x00 0x00 at the end of an indefinite length
34673467
* returns the number of bytes written */
3468-
word32 SetIndefEnd(byte* in)
3468+
word32 SetIndefEnd(byte* output)
34693469
{
3470-
byte terminate[] = { 0x00, 0x00 };
3470+
byte terminate[ASN_INDEF_END_SZ] = { 0x00, 0x00 };
34713471

3472-
if (in != NULL) {
3473-
XMEMCPY(in, terminate, 2);
3472+
if (output != NULL) {
3473+
XMEMCPY(output, terminate, ASN_INDEF_END_SZ);
34743474
}
3475-
return 2;
3475+
3476+
return (word32)ASN_INDEF_END_SZ;
34763477
}
34773478

34783479

34793480
/* Breaks an octet string up into chunks for use with streaming
34803481
* returns 0 on success and updates idx */
3481-
int StreamOctetString(const byte* in, word32 inSz, byte* out, word32* outSz,
3482+
int StreamOctetString(const byte* inBuf, word32 inBufSz, byte* out, word32* outSz,
34823483
word32* idx)
34833484
{
34843485
word32 i = 0;
@@ -3487,13 +3488,13 @@ int StreamOctetString(const byte* in, word32 inSz, byte* out, word32* outSz,
34873488

34883489
if (tmp) tmp += outIdx;
34893490

3490-
while (i < inSz) {
3491-
int ret, sz;
3491+
while (i < inBufSz) {
3492+
word32 ret, sz;
34923493

34933494
sz = BER_OCTET_LENGTH;
34943495

3495-
if ((sz + i) > inSz) {
3496-
sz = inSz - i;
3496+
if ((sz + i) > inBufSz) {
3497+
sz = inBufSz - i;
34973498
}
34983499

34993500
ret = SetOctetString(sz, tmp);
@@ -3502,10 +3503,10 @@ int StreamOctetString(const byte* in, word32 inSz, byte* out, word32* outSz,
35023503
}
35033504

35043505
if (tmp) {
3505-
if (ret + sz + i + outIdx > *outSz) {
3506+
if ((word32)ret + sz + i + outIdx > *outSz) {
35063507
return BUFFER_E;
35073508
}
3508-
XMEMCPY(tmp + ret, in + i, sz);
3509+
XMEMCPY(tmp + ret, inBuf + i, sz);
35093510
tmp += sz + ret;
35103511
}
35113512
outIdx += sz;

wolfssl/wolfcrypt/asn.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2101,8 +2101,8 @@ WOLFSSL_LOCAL int GetName(DecodedCert* cert, int nameType, int maxIdx);
21012101

21022102
WOLFSSL_ASN_API int wc_BerToDer(const byte* ber, word32 berSz, byte* der,
21032103
word32* derSz);
2104-
WOLFSSL_LOCAL int StreamOctetString(const byte* in, word32 inSz, byte* out, word32* outSz,
2105-
word32* idx);
2104+
WOLFSSL_LOCAL int StreamOctetString(const byte* inBuf, word32 inBufSz,
2105+
byte* out, word32* outSz, word32* idx);
21062106

21072107
WOLFSSL_ASN_API void FreeAltNames(DNS_entry* altNames, void* heap);
21082108
WOLFSSL_ASN_API DNS_entry* AltNameNew(void* heap);
@@ -2280,7 +2280,7 @@ WOLFSSL_LOCAL word32 SetLength(word32 length, byte* output);
22802280
WOLFSSL_LOCAL word32 SetLengthEx(word32 length, byte* output, byte isIndef);
22812281
WOLFSSL_LOCAL word32 SetSequence(word32 len, byte* output);
22822282
WOLFSSL_LOCAL word32 SetSequenceEx(word32 len, byte* output, byte isIndef);
2283-
WOLFSSL_LOCAL word32 SetIndefEnd(byte* in);
2283+
WOLFSSL_LOCAL word32 SetIndefEnd(byte* output);
22842284
WOLFSSL_LOCAL word32 SetOctetString(word32 len, byte* output);
22852285
WOLFSSL_LOCAL word32 SetOctetStringEx(word32 len, byte* output, byte indef);
22862286
WOLFSSL_LOCAL int SetASNInt(int len, byte firstByte, byte* output);

0 commit comments

Comments
 (0)