Merge pull request #10551 from akallabeth/arch-fixes

Arch fixes
This commit is contained in:
akallabeth 2024-09-04 09:56:35 +02:00 committed by GitHub
commit b6e72c7674
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 54 additions and 14 deletions

View File

@ -826,7 +826,7 @@ static BOOL tls_prepare(rdpTls* tls, BIO* underlying, SSL_METHOD* method, int op
return TRUE;
}
static void adjustSslOptions(const int* options)
static void adjustSslOptions(int* options)
{
WINPR_ASSERT(options);
#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)

View File

@ -24,6 +24,7 @@
#include <winpr/user.h>
#include <winpr/image.h>
#include "../utils/image.h"
#include "clipboard.h"
static const char* mime_bitmap[] = { "image/bmp", "image/x-bmp", "image/x-MS-bmp",
@ -234,14 +235,10 @@ static void* clipboard_synthesize_cf_dib(wClipboard* clipboard, UINT32 formatId,
}
else if (is_format_bitmap(clipboard, formatId))
{
const BITMAPFILEHEADER* pFileHeader = NULL;
if (SrcSize < (sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER)))
return NULL;
pFileHeader = (const BITMAPFILEHEADER*)data;
if (pFileHeader->bfType != 0x4D42)
WINPR_BITMAP_FILE_HEADER pFileHeader = { 0 };
wStream sbuffer = { 0 };
wStream* s = Stream_StaticConstInit(&sbuffer, data, SrcSize);
if (!readBitmapFileHeader(s, &pFileHeader))
return NULL;
DstSize = SrcSize - sizeof(BITMAPFILEHEADER);

View File

@ -49,6 +49,7 @@
#endif
#include <winpr/stream.h>
#include "image.h"
#include "../log.h"
#define TAG WINPR_TAG("utils.image")
@ -73,9 +74,14 @@ static BOOL writeBitmapFileHeader(wStream* s, const WINPR_BITMAP_FILE_HEADER* bf
return TRUE;
}
static BOOL readBitmapFileHeader(wStream* s, WINPR_BITMAP_FILE_HEADER* bf)
BOOL readBitmapFileHeader(wStream* s, WINPR_BITMAP_FILE_HEADER* bf)
{
if (!s || !bf || (!Stream_CheckAndLogRequiredLength(TAG, s, sizeof(WINPR_BITMAP_FILE_HEADER))))
static wLog* log = NULL;
if (!log)
log = WLog_Get(TAG);
if (!s || !bf ||
(!Stream_CheckAndLogRequiredLengthWLog(log, s, sizeof(WINPR_BITMAP_FILE_HEADER))))
return FALSE;
Stream_Read_UINT8(s, bf->bfType[0]);
@ -87,12 +93,19 @@ static BOOL readBitmapFileHeader(wStream* s, WINPR_BITMAP_FILE_HEADER* bf)
if (bf->bfSize < sizeof(WINPR_BITMAP_FILE_HEADER))
{
WLog_ERR(TAG, "");
WLog_Print(log, WLOG_ERROR, "Invalid bitmap::bfSize=%" PRIu32 ", require at least %" PRIuz,
bf->bfSize, sizeof(WINPR_BITMAP_FILE_HEADER));
return FALSE;
}
return Stream_CheckAndLogRequiredCapacity(TAG, s,
bf->bfSize - sizeof(WINPR_BITMAP_FILE_HEADER));
if ((bf->bfType[0] != 'B') || (bf->bfType[1] != 'M'))
{
WLog_Print(log, WLOG_ERROR, "Invalid bitmap header [%c%c], expected [BM]", bf->bfType[0],
bf->bfType[1]);
return FALSE;
}
return Stream_CheckAndLogRequiredCapacityWLog(log, s,
bf->bfSize - sizeof(WINPR_BITMAP_FILE_HEADER));
}
static BOOL writeBitmapInfoHeader(wStream* s, const WINPR_BITMAP_INFO_HEADER* bi)

View File

@ -0,0 +1,30 @@
/*
* WinPR: Windows Portable Runtime
* Image Utils
*
* Copyright 2024 Armin Novak <anovak@thincast.com>
* Copyright 2024 Thincast Technologies GmbH
*
* 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.
*/
#ifndef LIBWINPR_UTILS_IMAGE_H
#define LIBWINPR_UTILS_IMAGE_H
#include <winpr/wtypes.h>
#include <winpr/stream.h>
#include <winpr/image.h>
BOOL readBitmapFileHeader(wStream* s, WINPR_BITMAP_FILE_HEADER* bf);
#endif /* LIBWINPR_UTILS_IMAGE_H */