Skip to content

Commit

Permalink
Merge branch 'main' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
dcommander committed Dec 19, 2024
2 parents e1cf440 + f071dba commit dc67216
Show file tree
Hide file tree
Showing 18 changed files with 807 additions and 120 deletions.
5 changes: 5 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ should now be specified by prefixing the VNC host or the gateway host with the
username followed by @. This fixes an issue whereby separate SSH usernames
could not be specified for the `Server` and `Via` parameters.

11. The TurboVNC Server now includes various security fixes (CVE-2023-5367,
CVE-2023-6377, CVE-2023-6478, CVE-2023-6816, CVE-2024-0229, CVE-2024-0408,
CVE-2024-9632, CVE-2024-21885, CVE-2024-21886, CVE-2024-31080, CVE-2024-31081,
and CVE-2024-31083) from the xorg-server 21.1.x code base.


3.1.3
=====
Expand Down
10 changes: 5 additions & 5 deletions common/turbojpeg-jni/turbojpeg-jni.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Copyright (C) 2011-2012, 2014-2015, 2017-2019, 2021 D. R. Commander.
* All Rights Reserved.
/* Copyright (C) 2011-2012, 2014-2015, 2017-2019, 2021, 2024
* D. R. Commander. All Rights Reserved.
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -63,7 +63,7 @@ JNIEXPORT jlong JNICALL Java_com_turbovnc_rfb_TightDecoder_tjInitDecompress
THROW(tjGetErrorStr());

bailout:
return (jlong)handle;
return (jlong)(size_t)handle;
}


Expand All @@ -88,7 +88,7 @@ static void decompress
BAILIF0NOEC(jpegBuf = (*env)->GetPrimitiveArrayCritical(env, src, 0));
BAILIF0NOEC(dstBuf = (*env)->GetPrimitiveArrayCritical(env, dst, 0));

if (tjDecompress2((tjhandle)handle, jpegBuf, (unsigned long)jpegSize,
if (tjDecompress2((tjhandle)(size_t)handle, jpegBuf, (unsigned long)jpegSize,
&dstBuf[y * actualPitch + x * tjPixelSize[pf]], width,
pitch, height, pf, flags) == -1) {
SAFE_RELEASE(dst, dstBuf);
Expand Down Expand Up @@ -128,7 +128,7 @@ JNIEXPORT void JNICALL Java_com_turbovnc_rfb_TightDecoder_tjDestroy
if (!handle)
THROW("Invalid argument in tjDestroy()");

if (tjDestroy((tjhandle)handle) == -1) THROW(tjGetErrorStr());
if (tjDestroy((tjhandle)(size_t)handle) == -1) THROW(tjGetErrorStr());

bailout:
return;
Expand Down
13 changes: 7 additions & 6 deletions unix/Xvnc/programs/Xserver/Xi/exevents.c
Original file line number Diff line number Diff line change
Expand Up @@ -561,19 +561,20 @@ DeepCopyPointerClasses(DeviceIntPtr from, DeviceIntPtr to)
to->button = calloc(1, sizeof(ButtonClassRec));
if (!to->button)
FatalError("[Xi] no memory for class shift.\n");
to->button->numButtons = from->button->numButtons;
}
else
classes->button = NULL;
}

if (from->button->xkb_acts) {
if (!to->button->xkb_acts) {
to->button->xkb_acts = calloc(1, sizeof(XkbAction));
if (!to->button->xkb_acts)
FatalError("[Xi] not enough memory for xkb_acts.\n");
}
size_t maxbuttons = max(to->button->numButtons, from->button->numButtons);
to->button->xkb_acts = xnfreallocarray(to->button->xkb_acts,
maxbuttons,
sizeof(XkbAction));
memset(to->button->xkb_acts, 0, maxbuttons * sizeof(XkbAction));
memcpy(to->button->xkb_acts, from->button->xkb_acts,
sizeof(XkbAction));
from->button->numButtons * sizeof(XkbAction));
}
else {
free(to->button->xkb_acts);
Expand Down
27 changes: 22 additions & 5 deletions unix/Xvnc/programs/Xserver/Xi/xichangehierarchy.c
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,11 @@ ProcXIChangeHierarchy(ClientPtr client)
size_t len; /* length of data remaining in request */
int rc = Success;
int flags[MAXDEVICES] = { 0 };
enum {
NO_CHANGE,
FLUSH,
CHANGED,
} changes = NO_CHANGE;

REQUEST(xXIChangeHierarchyReq);
REQUEST_AT_LEAST_SIZE(xXIChangeHierarchyReq);
Expand Down Expand Up @@ -465,8 +470,9 @@ ProcXIChangeHierarchy(ClientPtr client)
rc = add_master(client, c, flags);
if (rc != Success)
goto unwind;
}
changes = FLUSH;
break;
}
case XIRemoveMaster:
{
xXIRemoveMasterInfo *r = (xXIRemoveMasterInfo *) any;
Expand All @@ -475,8 +481,9 @@ ProcXIChangeHierarchy(ClientPtr client)
rc = remove_master(client, r, flags);
if (rc != Success)
goto unwind;
}
changes = FLUSH;
break;
}
case XIDetachSlave:
{
xXIDetachSlaveInfo *c = (xXIDetachSlaveInfo *) any;
Expand All @@ -485,8 +492,9 @@ ProcXIChangeHierarchy(ClientPtr client)
rc = detach_slave(client, c, flags);
if (rc != Success)
goto unwind;
}
changes = CHANGED;
break;
}
case XIAttachSlave:
{
xXIAttachSlaveInfo *c = (xXIAttachSlaveInfo *) any;
Expand All @@ -495,16 +503,25 @@ ProcXIChangeHierarchy(ClientPtr client)
rc = attach_slave(client, c, flags);
if (rc != Success)
goto unwind;
changes = CHANGED;
break;
}
default:
break;
}

if (changes == FLUSH) {
XISendDeviceHierarchyEvent(flags);
memset(flags, 0, sizeof(flags));
changes = NO_CHANGE;
}

len -= any->length * 4;
any = (xXIAnyHierarchyChangeInfo *) ((char *) any + any->length * 4);
}

unwind:

XISendDeviceHierarchyEvent(flags);
if (changes != NO_CHANGE)
XISendDeviceHierarchyEvent(flags);
return rc;
}
5 changes: 4 additions & 1 deletion unix/Xvnc/programs/Xserver/Xi/xipassivegrab.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ ProcXIPassiveGrabDevice(ClientPtr client)
GrabParameters param;
void *tmp;
int mask_len;
uint32_t length;

REQUEST(xXIPassiveGrabDeviceReq);
REQUEST_FIXED_SIZE(xXIPassiveGrabDeviceReq,
Expand Down Expand Up @@ -234,9 +235,11 @@ ProcXIPassiveGrabDevice(ClientPtr client)
}
}

/* save the value before SRepXIPassiveGrabDevice swaps it */
length = rep.length;
WriteReplyToClient(client, sizeof(rep), &rep);
if (rep.num_modifiers)
WriteToClient(client, rep.length * 4, modifiers_failed);
WriteToClient(client, length * 4, modifiers_failed);

out:
free(modifiers_failed);
Expand Down
4 changes: 2 additions & 2 deletions unix/Xvnc/programs/Xserver/Xi/xiproperty.c
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,7 @@ XIChangeDeviceProperty(DeviceIntPtr dev, Atom property, Atom type,
XIDestroyDeviceProperty(prop);
return BadAlloc;
}
new_value.size = len;
new_value.size = total_len;
new_value.type = type;
new_value.format = format;

Expand All @@ -747,7 +747,7 @@ XIChangeDeviceProperty(DeviceIntPtr dev, Atom property, Atom type,
case PropModePrepend:
new_data = new_value.data;
old_data = (void *) (((char *) new_value.data) +
(prop_value->size * size_in_bytes));
(len * size_in_bytes));
break;
}
if (new_data)
Expand Down
3 changes: 1 addition & 2 deletions unix/Xvnc/programs/Xserver/Xi/xiquerypointer.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,7 @@ ProcXIQueryPointer(ClientPtr client)
if (pDev->button) {
int i;

rep.buttons_len =
bytes_to_int32(bits_to_bytes(pDev->button->numButtons));
rep.buttons_len = bytes_to_int32(bits_to_bytes(256)); /* button map up to 255 */
rep.length += rep.buttons_len;
buttons = calloc(rep.buttons_len, 4);
if (!buttons)
Expand Down
5 changes: 4 additions & 1 deletion unix/Xvnc/programs/Xserver/Xi/xiselectev.c
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ ProcXIGetSelectedEvents(ClientPtr client)
InputClientsPtr others = NULL;
xXIEventMask *evmask = NULL;
DeviceIntPtr dev;
uint32_t length;

REQUEST(xXIGetSelectedEventsReq);
REQUEST_SIZE_MATCH(xXIGetSelectedEventsReq);
Expand Down Expand Up @@ -366,10 +367,12 @@ ProcXIGetSelectedEvents(ClientPtr client)
}
}

/* save the value before SRepXIGetSelectedEvents swaps it */
length = reply.length;
WriteReplyToClient(client, sizeof(xXIGetSelectedEventsReply), &reply);

if (reply.num_masks)
WriteToClient(client, reply.length * 4, buffer);
WriteToClient(client, length * 4, buffer);

free(buffer);
return Success;
Expand Down
37 changes: 34 additions & 3 deletions unix/Xvnc/programs/Xserver/dix/devices.c
Original file line number Diff line number Diff line change
Expand Up @@ -451,14 +451,20 @@ DisableDevice(DeviceIntPtr dev, BOOL sendevent)
{
DeviceIntPtr *prev, other;
BOOL enabled;
BOOL dev_in_devices_list = FALSE;
int flags[MAXDEVICES] = { 0 };

if (!dev->enabled)
return TRUE;

for (prev = &inputInfo.devices;
*prev && (*prev != dev); prev = &(*prev)->next);
if (*prev != dev)
for (other = inputInfo.devices; other; other = other->next) {
if (other == dev) {
dev_in_devices_list = TRUE;
break;
}
}

if (!dev_in_devices_list)
return FALSE;

TouchEndPhysicallyActiveTouches(dev);
Expand All @@ -474,6 +480,13 @@ DisableDevice(DeviceIntPtr dev, BOOL sendevent)
flags[other->id] |= XISlaveDetached;
}
}

for (other = inputInfo.off_devices; other; other = other->next) {
if (!IsMaster(other) && GetMaster(other, MASTER_ATTACHED) == dev) {
AttachDevice(NULL, other, NULL);
flags[other->id] |= XISlaveDetached;
}
}
}
else {
for (other = inputInfo.devices; other; other = other->next) {
Expand Down Expand Up @@ -508,6 +521,9 @@ DisableDevice(DeviceIntPtr dev, BOOL sendevent)
LeaveWindow(dev);
SetFocusOut(dev);

for (prev = &inputInfo.devices;
*prev && (*prev != dev); prev = &(*prev)->next);

*prev = dev->next;
dev->next = inputInfo.off_devices;
inputInfo.off_devices = dev;
Expand Down Expand Up @@ -1067,6 +1083,11 @@ CloseDownDevices(void)
dev->master = NULL;
}

for (dev = inputInfo.off_devices; dev; dev = dev->next) {
if (!IsMaster(dev) && !IsFloating(dev))
dev->master = NULL;
}

CloseDeviceList(&inputInfo.devices);
CloseDeviceList(&inputInfo.off_devices);

Expand Down Expand Up @@ -2502,6 +2523,8 @@ RecalculateMasterButtons(DeviceIntPtr slave)

if (master->button && master->button->numButtons != maxbuttons) {
int i;
int last_num_buttons = master->button->numButtons;

DeviceChangedEvent event = {
.header = ET_Internal,
.type = ET_DeviceChanged,
Expand All @@ -2512,6 +2535,14 @@ RecalculateMasterButtons(DeviceIntPtr slave)
};

master->button->numButtons = maxbuttons;
if (last_num_buttons < maxbuttons) {
master->button->xkb_acts = xnfreallocarray(master->button->xkb_acts,
maxbuttons,
sizeof(XkbAction));
memset(&master->button->xkb_acts[last_num_buttons],
0,
(maxbuttons - last_num_buttons) * sizeof(XkbAction));
}

memcpy(&event.buttons.names, master->button->labels, maxbuttons *
sizeof(Atom));
Expand Down
Loading

0 comments on commit dc67216

Please sign in to comment.