提交 e9cf2fe0 编写于 作者: D Daniel P. Berrange

qemu-char: convert to use error checked base64 decode

Switch from using g_base64_decode over to qbase64_decode
in order to get error checking of the base64 input data.
Reviewed-by: NEric Blake <eblake@redhat.com>
Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
上级 89bc0b6c
......@@ -295,8 +295,6 @@
# @format: #optional data encoding (default 'utf8').
# - base64: data must be base64 encoded text. Its binary
# decoding gets written.
# Bug: invalid base64 is currently not rejected.
# Whitespace *is* invalid.
# - utf8: data's UTF-8 encoding is written
# - data itself is always Unicode regardless of format, like
# any other string.
......
......@@ -32,6 +32,7 @@
#include "qapi/qmp-input-visitor.h"
#include "qapi/qmp-output-visitor.h"
#include "qapi-visit.h"
#include "qemu/base64.h"
#include <unistd.h>
#include <fcntl.h>
......@@ -3264,7 +3265,12 @@ void qmp_ringbuf_write(const char *device, const char *data,
}
if (has_format && (format == DATA_FORMAT_BASE64)) {
write_data = g_base64_decode(data, &write_count);
write_data = qbase64_decode(data, -1,
&write_count,
errp);
if (!write_data) {
return;
}
} else {
write_data = (uint8_t *)data;
write_count = strlen(data);
......
......@@ -512,8 +512,6 @@ Arguments:
- "data": data to write (json-string)
- "format": data format (json-string, optional)
- Possible values: "utf8" (default), "base64"
Bug: invalid base64 is currently not rejected.
Whitespace *is* invalid.
Example:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册