mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-30 10:47:28 +02:00
Update Base16_Encode so the ending null terminator is optional.
This commit is contained in:
@ -563,7 +563,7 @@ int Base16_Encode(const byte* in, word32 inLen, byte* out, word32* outLen)
|
|||||||
if (in == NULL || out == NULL || outLen == NULL)
|
if (in == NULL || out == NULL || outLen == NULL)
|
||||||
return BAD_FUNC_ARG;
|
return BAD_FUNC_ARG;
|
||||||
|
|
||||||
if (*outLen < (2 * inLen + 1))
|
if (*outLen < (2 * inLen))
|
||||||
return BAD_FUNC_ARG;
|
return BAD_FUNC_ARG;
|
||||||
|
|
||||||
for (i = 0; i < inLen; i++) {
|
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;
|
out[outIdx++] = lb;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* force 0 at this end */
|
/* If the output buffer has a room for an extra byte, add a null terminator */
|
||||||
out[outIdx++] = 0;
|
if (*outLen > outIdx)
|
||||||
|
out[outIdx++]= '\0';
|
||||||
|
|
||||||
*outLen = outIdx;
|
*outLen = outIdx;
|
||||||
return 0;
|
return 0;
|
||||||
|
Reference in New Issue
Block a user