1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-09 00:00:04 +01:00

base64: prevent writing null char into zero length output buffer

This allows handling of the unusal but foreseeable situation were
the client provides a zero length output buffer, for example, if
the input buffer was also zero length.
This commit is contained in:
Michael Drake 2022-01-09 12:46:27 +00:00 committed by Andy Green
parent c735a9f383
commit 781c6f3227

View file

@ -164,7 +164,9 @@ lws_b64_decode_stateful(struct lws_b64state *s, const char *in, size_t *in_len,
s->len = 0;
}
*out = '\0';
if (out < end_out)
*out = '\0';
*in_len = (unsigned int)(in - orig_in);
*out_size = (unsigned int)(out - orig_out);