You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[2025/02/17 17:29:31:9128] E: _lws_b64_decode_string: base64 must end at end of input
I looked into it and fixed it (see below a patch). Is there a guide on howto send this upstream?
The external lws_b64_decode_string and internal _lws_b64_decode_string
do not require an input string length, and this is when strlen is used
to get the length and compare it against the
"length-of-the-input-actually-decoded".
The comparison forgets no input string length might be given and so
_lws_b64_decode_string might fail with "base64 must end at end of input".
This can be easily fixed by using strlen right away to pass the
input string length to _lws_b64_decode_string.
---
lib/misc/base64-decode.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/lib/misc/base64-decode.c b/lib/misc/base64-decode.c
index 8f0a735d..332325cc 100644
--- a/lib/misc/base64-decode.c
+++ b/lib/misc/base64-decode.c
@@ -203,8 +203,7 @@ lws_b64_decode_stateful(struct lws_b64state *s, const char *in, size_t *in_len,
* returns length of decoded string in out, or -1 if out was too small
* according to out_size
*
- * Only reads up to in_len chars, otherwise if in_len is -1 on entry reads until
- * the first NUL in the input.
+ * Only reads up to in_len chars.
*/
static size_t
@@ -213,9 +212,6 @@ _lws_b64_decode_string(const char *in, int in_len, char *out, size_t out_size)
struct lws_b64state state;
size_t il = (size_t)in_len, ol = out_size;
- if (in_len == -1)
- il = strlen(in);
-
lws_b64_decode_state_init(&state);
if (lws_b64_decode_stateful(&state, in, &il, (uint8_t *)out, &ol, 1) < 0)
/* pass on the failure */
@@ -229,10 +225,15 @@ _lws_b64_decode_string(const char *in, int in_len, char *out, size_t out_size)
return ol;
}
+
+/*
+ * reads until the first NUL in the input.
+ */
+
int
lws_b64_decode_string(const char *in, char *out, int out_size)
{
- return (int)_lws_b64_decode_string(in, -1, out, (unsigned int)out_size);
+ return (int)_lws_b64_decode_string(in, (int)strlen(in), out, (unsigned int)out_size);
}
int
--
2.47.1
The text was updated successfully, but these errors were encountered:
lws_b64_decode_string always fails, see:
[2025/02/17 17:29:31:9128] E: _lws_b64_decode_string: base64 must end at end of input
I looked into it and fixed it (see below a patch). Is there a guide on howto send this upstream?
The text was updated successfully, but these errors were encountered: