Commit 2b5d90be authored by Travis Skare's avatar Travis Skare Committed by Commit Bot

[QRCode Generator] (fuzzer) guard against null-data in inner service.

Remove a line that was an error but did not surface as a bug.
Add some comments around the method in question for readability.

Bug: 1111685
Change-Id: I0bb763a87d9062bd18bccacea9aee130814ee1a5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2365394Reviewed-by: default avatarJeffrey Cohen <jeffreycohen@chromium.org>
Commit-Queue: Travis Skare <skare@chromium.org>
Cr-Commit-Position: refs/heads/master@{#801210}
parent d04cef4c
......@@ -270,7 +270,8 @@ void QRCodeGeneratorServiceImpl::GenerateQRCode(
qr.Generate(base::span<const uint8_t>(
reinterpret_cast<const uint8_t*>(request->data.data()),
request->data.size()));
if (!qr_data) {
if (!qr_data || qr_data->data.data() == nullptr ||
qr_data->data.size() == 0) {
// The above check should have caught the too-long-URL case.
// Remaining errors can be treated as UNKNOWN.
response->error_code = mojom::QRCodeGeneratorError::UNKNOWN_ERROR;
......@@ -287,10 +288,9 @@ void QRCodeGeneratorServiceImpl::GenerateQRCode(
response->data.insert(response->data.begin(), qr_data_span.begin(),
qr_data_span.end());
response->data_size = {qr_data_span.size(), qr_data_span.size()};
response->data_size = {qr_data->qr_size, qr_data->qr_size};
response->error_code = mojom::QRCodeGeneratorError::NONE;
gfx::Size qr_output_data_size = {qr_data->qr_size, qr_data->qr_size};
RenderBitmap(qr_data_span.data(), qr_output_data_size, request, &response);
RenderBitmap(qr_data_span.data(), response->data_size, request, &response);
std::move(callback).Run(std::move(response));
}
......
......@@ -48,6 +48,14 @@ class QRCodeGeneratorServiceImpl : public mojom::QRCodeGeneratorService {
// Renders the QR code with pixel information in |data| and render parameters
// in |request|. Result is stored into |response|.
// |data| is input data, one element per module, row-major.
// |data_size| is the dimensions of |data|, in modules. Currently expected to
// be square, but function should cope with other shapes.
// |request| is the mojo service request object to Generate().
// It includes rendering style preferences expressed by the client.
// |response| is the mojo service request object to Generate().
// The bitmap will be populated as a response field if requested by the
// client.
void RenderBitmap(const uint8_t* data,
const gfx::Size data_size,
const mojom::GenerateQRCodeRequestPtr& request,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment