mirror of
https://github.com/morgan9e/FreeRDP
synced 2026-04-15 00:44:19 +09:00
@@ -132,7 +132,8 @@ static size_t demux_uvcH264(const BYTE* srcData, size_t srcSize, BYTE* h264_data
|
||||
if (spl[0] != 0xFF || spl[1] != 0xE4)
|
||||
{
|
||||
WLog_ERR(TAG, "Expected 2nd+ APP4 marker but none found");
|
||||
return ph264 - h264_data;
|
||||
const intptr_t diff = ph264 - h264_data;
|
||||
return WINPR_ASSERTING_INT_CAST(size_t, diff);
|
||||
}
|
||||
|
||||
/* 2nd+ segment length in big endian */
|
||||
@@ -153,7 +154,8 @@ static size_t demux_uvcH264(const BYTE* srcData, size_t srcSize, BYTE* h264_data
|
||||
spl += length;
|
||||
}
|
||||
|
||||
return ph264 - h264_data;
|
||||
const intptr_t diff = ph264 - h264_data;
|
||||
return WINPR_ASSERTING_INT_CAST(size_t, diff);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -318,10 +318,10 @@ static BOOL get_devpath_from_device(libusb_device* device, char* path, size_t si
|
||||
for (int i = 0; i < nPorts; i++)
|
||||
{
|
||||
int nChars = snprintf(path, size, "%" PRIu8, ports[i]);
|
||||
if ((nChars <= 0) || (nChars >= size))
|
||||
if ((nChars <= 0) || ((size_t)nChars >= size))
|
||||
return FALSE;
|
||||
|
||||
size -= nChars;
|
||||
size -= (size_t)nChars;
|
||||
path += nChars;
|
||||
|
||||
if (i < nPorts - 1)
|
||||
@@ -382,11 +382,11 @@ static uint8_t get_guid_unit_id_from_device(libusb_device* device, const uint8_t
|
||||
desc->bDescriptorSubType == USB_VIDEO_CONTROL_XU_TYPE &&
|
||||
memcmp(desc->guidExtensionCode, guid, 16) == 0)
|
||||
{
|
||||
uint8_t unit_id = desc->bUnitID;
|
||||
int8_t unit_id = desc->bUnitID;
|
||||
|
||||
WLog_DBG(TAG,
|
||||
"For camera %04" PRIx16 ":%04" PRIx16
|
||||
" found UVCX H264 UnitID %" PRIu8,
|
||||
" found UVCX H264 UnitID %" PRId8,
|
||||
ddesc.idVendor, ddesc.idProduct, unit_id);
|
||||
return unit_id;
|
||||
}
|
||||
|
||||
@@ -81,18 +81,25 @@ int SdlSelectList::run()
|
||||
else if (_list.empty())
|
||||
CurrentActiveTextInput = 0;
|
||||
else
|
||||
CurrentActiveTextInput =
|
||||
WINPR_ASSERTING_INT_CAST(ssize_t, _list.size()) - 1;
|
||||
{
|
||||
auto s = _list.size();
|
||||
CurrentActiveTextInput = WINPR_ASSERTING_INT_CAST(ssize_t, s) - 1;
|
||||
}
|
||||
break;
|
||||
case SDLK_DOWN:
|
||||
case SDLK_TAB:
|
||||
if ((CurrentActiveTextInput < 0) || _list.empty())
|
||||
CurrentActiveTextInput = 0;
|
||||
else
|
||||
{
|
||||
auto s = _list.size();
|
||||
CurrentActiveTextInput++;
|
||||
CurrentActiveTextInput =
|
||||
CurrentActiveTextInput %
|
||||
WINPR_ASSERTING_INT_CAST(ssize_t, _list.size());
|
||||
if (s > 0)
|
||||
{
|
||||
CurrentActiveTextInput = CurrentActiveTextInput %
|
||||
WINPR_ASSERTING_INT_CAST(ssize_t, s);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SDLK_RETURN:
|
||||
case SDLK_RETURN2:
|
||||
|
||||
@@ -511,10 +511,10 @@ UINT sdlClip::ReceiveServerFormatList(CliprdrClientContext* context,
|
||||
clipboard->_current_mimetypes.push_back(s_mime_mate_copied_files);
|
||||
}
|
||||
|
||||
auto s = clipboard->_current_mimetypes.size();
|
||||
SDL_Event ev = { SDL_EVENT_CLIPBOARD_UPDATE };
|
||||
ev.clipboard.owner = true;
|
||||
ev.clipboard.num_mime_types =
|
||||
WINPR_ASSERTING_INT_CAST(Sint32, clipboard->_current_mimetypes.size());
|
||||
ev.clipboard.num_mime_types = WINPR_ASSERTING_INT_CAST(Sint32, s);
|
||||
ev.clipboard.mime_types = clipboard->_current_mimetypes.data();
|
||||
|
||||
/* TODO: Hack to identify our own updates */
|
||||
|
||||
@@ -574,9 +574,9 @@ BOOL xf_detect_monitors(xfContext* xfc, UINT32* pMaxWidth, UINT32* pMaxHeight)
|
||||
|
||||
if (freerdp_settings_get_bool(settings, FreeRDP_Workarea))
|
||||
{
|
||||
INT64 bottom = xfc->workArea.height + xfc->workArea.y - 1;
|
||||
vscreen->area.top = WINPR_ASSERTING_INT_CAST(UINT16, xfc->workArea.y);
|
||||
vscreen->area.bottom =
|
||||
WINPR_ASSERTING_INT_CAST(UINT16, xfc->workArea.height + xfc->workArea.y - 1);
|
||||
vscreen->area.bottom = WINPR_ASSERTING_INT_CAST(UINT16, bottom);
|
||||
}
|
||||
|
||||
if (!primaryMonitorFound)
|
||||
|
||||
@@ -88,7 +88,6 @@ static int freerdp_connect_begin(freerdp* instance)
|
||||
rdpRdp* rdp = NULL;
|
||||
BOOL status = TRUE;
|
||||
rdpSettings* settings = NULL;
|
||||
UINT32 KeyboardLayout = 0;
|
||||
|
||||
if (!instance)
|
||||
return -1;
|
||||
@@ -131,7 +130,7 @@ static int freerdp_connect_begin(freerdp* instance)
|
||||
status = utils_reload_channels(instance->context);
|
||||
|
||||
const UINT32 cp = freerdp_settings_get_uint32(settings, FreeRDP_KeyboardCodePage);
|
||||
KeyboardLayout = freerdp_get_keyboard_default_layout_for_locale(cp);
|
||||
int64_t KeyboardLayout = freerdp_get_keyboard_default_layout_for_locale(cp);
|
||||
if (KeyboardLayout == 0)
|
||||
KeyboardLayout = freerdp_settings_get_uint32(settings, FreeRDP_KeyboardLayout);
|
||||
|
||||
|
||||
@@ -866,7 +866,7 @@ static INLINE BOOL update_read_delta(wStream* s, INT32* value)
|
||||
Stream_Read_UINT8(s, byte);
|
||||
|
||||
if (byte & 0x40)
|
||||
uvalue = (byte | ~0x3F);
|
||||
uvalue = (byte | ~0x3F) & UINT32_MAX;
|
||||
else
|
||||
uvalue = (byte & 0x3F);
|
||||
|
||||
|
||||
@@ -60,14 +60,14 @@ struct LanguageIdentifier
|
||||
|
||||
typedef struct
|
||||
{
|
||||
DWORD code; /* Keyboard layout code */
|
||||
INT64 code; /* Keyboard layout code */
|
||||
DWORD id; /* Keyboard variant ID */
|
||||
char* name; /* Keyboard layout variant name */
|
||||
} RDP_KEYBOARD_LAYOUT_VARIANT;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
DWORD code; /* Keyboard layout code */
|
||||
INT64 code; /* Keyboard layout code */
|
||||
char* file; /* IME file */
|
||||
char* name; /* Keyboard layout name */
|
||||
} RDP_KEYBOARD_IME;
|
||||
@@ -1109,6 +1109,23 @@ static UINT32 get_object_integer(WINPR_JSON* json, size_t pos, const char* name)
|
||||
return WINPR_JSON_GetNumberValue(obj);
|
||||
}
|
||||
|
||||
static bool parse_json_layout_entry_id(WINPR_JSON* json, size_t pos, RDP_KEYBOARD_LAYOUT* entry)
|
||||
{
|
||||
WINPR_ASSERT(entry);
|
||||
const int64_t code = get_object_integer(json, pos, "code");
|
||||
if ((code < INT32_MIN) || (code > UINT32_MAX))
|
||||
{
|
||||
WLog_WARN(TAG,
|
||||
"Invalid JSON 'code' entry at entry %" PRIuz
|
||||
", value out of range: %d <= %" PRId64 " <= %" PRIu32,
|
||||
pos, INT32_MIN, code, UINT32_MAX);
|
||||
return false;
|
||||
}
|
||||
entry->code = WINPR_CXX_COMPAT_CAST(uint32_t, code);
|
||||
entry->name = get_object_str(json, pos, "name");
|
||||
return entry->name != NULL;
|
||||
}
|
||||
|
||||
static BOOL parse_json_layout_entry(WINPR_JSON* json, size_t pos, RDP_KEYBOARD_LAYOUT* entry)
|
||||
{
|
||||
WINPR_ASSERT(entry);
|
||||
@@ -1118,9 +1135,7 @@ static BOOL parse_json_layout_entry(WINPR_JSON* json, size_t pos, RDP_KEYBOARD_L
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
entry->code = get_object_integer(json, pos, "code");
|
||||
entry->name = get_object_str(json, pos, "name");
|
||||
if (!entry->name)
|
||||
if (!parse_json_layout_entry_id(json, pos, entry))
|
||||
{
|
||||
clear_keyboard_layout(entry);
|
||||
return FALSE;
|
||||
@@ -1169,14 +1184,12 @@ static BOOL parse_json_variant_entry(WINPR_JSON* json, size_t pos,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
entry->code = get_object_integer(json, pos, "code");
|
||||
entry->id = get_object_integer(json, pos, "id");
|
||||
entry->name = get_object_str(json, pos, "name");
|
||||
if (!entry->name)
|
||||
if (!parse_json_layout_entry_id(json, pos, entry))
|
||||
{
|
||||
clear_keyboard_variant(entry);
|
||||
return FALSE;
|
||||
}
|
||||
entry->id = get_object_integer(json, pos, "id");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -1321,6 +1334,13 @@ static UINT32 rdp_keyboard_layout_by_name(const char* name)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static uint32_t internal2unsigned(int64_t code)
|
||||
{
|
||||
WINPR_ASSERT(code >= INT32_MIN);
|
||||
WINPR_ASSERT(code <= UINT32_MAX);
|
||||
return WINPR_CXX_COMPAT_CAST(uint32_t, code);
|
||||
}
|
||||
|
||||
static UINT32 rdp_keyboard_variant_by_name(const char* name)
|
||||
{
|
||||
WINPR_ASSERT(name);
|
||||
@@ -1330,7 +1350,7 @@ static UINT32 rdp_keyboard_variant_by_name(const char* name)
|
||||
{
|
||||
const RDP_KEYBOARD_LAYOUT_VARIANT* const variant = &sRDP_KEYBOARD_LAYOUT_VARIANT_TABLE[i];
|
||||
if (strcmp(variant->name, name) == 0)
|
||||
return variant->code;
|
||||
return internal2unsigned(variant->code);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -1344,7 +1364,7 @@ static UINT32 rdp_keyboard_ime_by_name(const char* name)
|
||||
{
|
||||
const RDP_KEYBOARD_IME* const ime = &sRDP_KEYBOARD_IME_TABLE[i];
|
||||
if (strcmp(ime->name, name) == 0)
|
||||
return ime->code;
|
||||
return internal2unsigned(ime->code);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -1405,7 +1425,7 @@ static BOOL rdp_keyboard_layout_clone_append(RDP_KEYBOARD_LAYOUT** layouts, size
|
||||
{
|
||||
const RDP_KEYBOARD_LAYOUT* const ime = &sRDP_KEYBOARD_LAYOUT_TABLE[i];
|
||||
RDP_KEYBOARD_LAYOUT* layout = &(*layouts)[i + offset];
|
||||
layout->code = ime->code;
|
||||
layout->code = internal2unsigned(ime->code);
|
||||
if (ime->name)
|
||||
layout->name = _strdup(ime->name);
|
||||
|
||||
@@ -1431,7 +1451,7 @@ static BOOL rdp_keyboard_variant_clone_append(RDP_KEYBOARD_LAYOUT** layouts, siz
|
||||
{
|
||||
const RDP_KEYBOARD_LAYOUT_VARIANT* const ime = &sRDP_KEYBOARD_LAYOUT_VARIANT_TABLE[i];
|
||||
RDP_KEYBOARD_LAYOUT* layout = &(*layouts)[i + offset];
|
||||
layout->code = ime->code;
|
||||
layout->code = internal2unsigned(ime->code);
|
||||
if (ime->name)
|
||||
layout->name = _strdup(ime->name);
|
||||
|
||||
@@ -1457,7 +1477,7 @@ static BOOL rdp_keyboard_ime_clone_append(RDP_KEYBOARD_LAYOUT** layouts, size_t*
|
||||
{
|
||||
const RDP_KEYBOARD_IME* const ime = &sRDP_KEYBOARD_IME_TABLE[i];
|
||||
RDP_KEYBOARD_LAYOUT* layout = &(*layouts)[i + offset];
|
||||
layout->code = ime->code;
|
||||
layout->code = internal2unsigned(ime->code);
|
||||
if (ime->name)
|
||||
layout->name = _strdup(ime->name);
|
||||
|
||||
|
||||
@@ -32,13 +32,13 @@
|
||||
typedef struct
|
||||
{
|
||||
const char* variant; /* XKB Keyboard layout variant */
|
||||
UINT32 keyboardLayoutID; /* Keyboard Layout ID */
|
||||
INT64 keyboardLayoutID; /* Keyboard Layout ID */
|
||||
} XKB_VARIANT;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const char* layout; /* XKB Keyboard layout */
|
||||
UINT32 keyboardLayoutID; /* Keyboard Layout ID */
|
||||
INT64 keyboardLayoutID; /* Keyboard Layout ID */
|
||||
const XKB_VARIANT* variants;
|
||||
} XKB_LAYOUT;
|
||||
|
||||
@@ -826,6 +826,13 @@ static const XKB_LAYOUT xkbLayouts[] = {
|
||||
{ "tm", KBD_TURKISH_Q, tm_variants }, /* Turkmenistan */
|
||||
};
|
||||
|
||||
static uint32_t convert(int64_t val)
|
||||
{
|
||||
WINPR_ASSERT(val <= UINT32_MAX);
|
||||
WINPR_ASSERT(val >= INT32_MIN);
|
||||
return WINPR_CXX_COMPAT_CAST(uint32_t, val);
|
||||
}
|
||||
|
||||
static UINT32 find_keyboard_layout_variant(const XKB_LAYOUT* layout, const char* variant)
|
||||
{
|
||||
WINPR_ASSERT(layout);
|
||||
@@ -838,12 +845,12 @@ static UINT32 find_keyboard_layout_variant(const XKB_LAYOUT* layout, const char*
|
||||
while (var->variant && (strlen(var->variant) != 0))
|
||||
{
|
||||
if (strcmp(var->variant, variant) == 0)
|
||||
return var->keyboardLayoutID;
|
||||
return convert(var->keyboardLayoutID);
|
||||
var++;
|
||||
}
|
||||
}
|
||||
|
||||
return layout->keyboardLayoutID;
|
||||
return convert(layout->keyboardLayoutID);
|
||||
}
|
||||
|
||||
UINT32 find_keyboard_layout_in_xorg_rules(const char* layout, const char* variant)
|
||||
|
||||
@@ -1031,9 +1031,7 @@ static int32_t file_get_size(const struct synthetic_file* file, UINT64* size)
|
||||
static UINT delegate_file_request_size(wClipboardDelegate* delegate,
|
||||
const wClipboardFileSizeRequest* request)
|
||||
{
|
||||
UINT error = NO_ERROR;
|
||||
UINT64 size = 0;
|
||||
struct synthetic_file* file = NULL;
|
||||
|
||||
if (!delegate || !delegate->clipboard || !request)
|
||||
return ERROR_BAD_ARGUMENTS;
|
||||
@@ -1041,15 +1039,16 @@ static UINT delegate_file_request_size(wClipboardDelegate* delegate,
|
||||
if (delegate->clipboard->sequenceNumber != delegate->clipboard->fileListSequenceNumber)
|
||||
return ERROR_INVALID_STATE;
|
||||
|
||||
file = ArrayList_GetItem(delegate->clipboard->localFiles, request->listIndex);
|
||||
struct synthetic_file* file =
|
||||
ArrayList_GetItem(delegate->clipboard->localFiles, request->listIndex);
|
||||
|
||||
if (!file)
|
||||
return ERROR_INDEX_ABSENT;
|
||||
|
||||
error = file_get_size(file, &size);
|
||||
|
||||
const int32_t s = file_get_size(file, &size);
|
||||
uint32_t error = 0;
|
||||
if (error)
|
||||
error = delegate->ClipboardFileSizeFailure(delegate, request, error);
|
||||
error = delegate->ClipboardFileSizeFailure(delegate, request, (UINT)s);
|
||||
else
|
||||
error = delegate->ClipboardFileSizeSuccess(delegate, request, size);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user