mirror of https://github.com/wolfSSL/wolfssl.git
Merge pull request #5612 from kareem-wolfssl/base16Ending
Update Base16_Encode so the ending null terminator is optional.pull/5625/head
commit
f113e92495
|
@ -563,7 +563,7 @@ int Base16_Encode(const byte* in, word32 inLen, byte* out, word32* outLen)
|
|||
if (in == NULL || out == NULL || outLen == NULL)
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
if (*outLen < (2 * inLen + 1))
|
||||
if (*outLen < (2 * inLen))
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
for (i = 0; i < inLen; i++) {
|
||||
|
@ -584,8 +584,9 @@ int Base16_Encode(const byte* in, word32 inLen, byte* out, word32* outLen)
|
|||
out[outIdx++] = lb;
|
||||
}
|
||||
|
||||
/* force 0 at this end */
|
||||
out[outIdx++] = 0;
|
||||
/* If the output buffer has a room for an extra byte, add a null terminator */
|
||||
if (*outLen > outIdx)
|
||||
out[outIdx++]= '\0';
|
||||
|
||||
*outLen = outIdx;
|
||||
return 0;
|
||||
|
|
Loading…
Reference in New Issue