aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/programs/Xserver/hw/nxagent/Rootless.c
diff options
context:
space:
mode:
authorReinhard Tartler <siretart@tauware.de>2011-10-10 17:59:00 +0200
committerReinhard Tartler <siretart@tauware.de>2011-10-10 17:59:00 +0200
commit39b738a67a14dde67b2a811d56ac84934fcef52d (patch)
tree514ab67cc6147ba0853b5908ddf78e4115ffef1d /nx-X11/programs/Xserver/hw/nxagent/Rootless.c
parente6db7e93608570765b3b6133ebb60d746c81aeeb (diff)
downloadnx-libs-39b738a67a14dde67b2a811d56ac84934fcef52d.tar.gz
nx-libs-39b738a67a14dde67b2a811d56ac84934fcef52d.tar.bz2
nx-libs-39b738a67a14dde67b2a811d56ac84934fcef52d.zip
Imported nxagent-3.5.0-2.tar.gznxagent/3.5.0-2
Summary: Imported nxagent-3.5.0-2.tar.gz Keywords: Imported nxagent-3.5.0-2.tar.gz into Git repository
Diffstat (limited to 'nx-X11/programs/Xserver/hw/nxagent/Rootless.c')
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Rootless.c62
1 files changed, 58 insertions, 4 deletions
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Rootless.c b/nx-X11/programs/Xserver/hw/nxagent/Rootless.c
index 612e71cf7..74d2d1fe5 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Rootless.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Rootless.c
@@ -1,6 +1,6 @@
/**************************************************************************/
/* */
-/* Copyright (c) 2001, 2010 NoMachine, http://www.nomachine.com/. */
+/* Copyright (c) 2001, 2011 NoMachine, http://www.nomachine.com/. */
/* */
/* NXAGENT, NX protocol compression and NX extensions to this software */
/* are copyright of NoMachine. Redistribution and use of the present */
@@ -625,6 +625,7 @@ int nxagentExportProperty(pWin, property, type, format, mode, nUnits, value)
{
XlibAtom *atoms = malloc(nUnits * sizeof(*atoms));
Atom *input = value;
+ char *atomName = NULL;
int i;
int j = 0;
@@ -644,7 +645,8 @@ int nxagentExportProperty(pWin, property, type, format, mode, nUnits, value)
* instead of just getting rid of the property.
*/
- if (strcmp(NameForAtom(input[i]), "_NET_WM_PING") != 0)
+ if ((atomName = NameForAtom(input[i])) != NULL &&
+ strcmp(atomName, "_NET_WM_PING") != 0)
{
atoms[j] = nxagentLocalToRemoteAtom(input[i]);
@@ -652,7 +654,7 @@ int nxagentExportProperty(pWin, property, type, format, mode, nUnits, value)
{
#ifdef WARNING
fprintf(stderr, "nxagentExportProperty: WARNING! Failed to convert local atom %ld [%s].\n",
- (long int) input[i], validateString(NameForAtom(input[i])));
+ (long int) input[i], validateString(atomName));
#endif
}
@@ -725,7 +727,57 @@ int nxagentExportProperty(pWin, property, type, format, mode, nUnits, value)
}
else
{
- XChangeProperty(nxagentDisplay, nxagentWindow(pWin), propertyX, typeX, format, mode, (void*)output, nUnits);
+ #ifdef TEST
+ fprintf(stderr, "nxagentExportProperty: Property [%lu] format [%i] "
+ "units [%lu].\n", propertyX, format, nUnits);
+ #endif
+
+ if ((format >> 3) * nUnits + sizeof(xChangePropertyReq) <
+ (MAX_REQUEST_SIZE << 2))
+ {
+ XChangeProperty(nxagentDisplay, nxagentWindow(pWin), propertyX, typeX,
+ format, mode, (void*)output, nUnits);
+ }
+ else if (mode == PropModeReplace)
+ {
+ int n;
+ char *data;
+
+ XDeleteProperty(nxagentDisplay, nxagentWindow(pWin), propertyX);
+
+ data = (char *) output;
+
+ while (nUnits > 0)
+ {
+ if ((format >> 3) * nUnits + sizeof(xChangePropertyReq) <
+ (MAX_REQUEST_SIZE << 2))
+ {
+ n = nUnits;
+ }
+ else
+ {
+ n = ((MAX_REQUEST_SIZE << 2) - sizeof(xChangePropertyReq)) /
+ (format >> 3);
+ }
+
+ XChangeProperty(nxagentDisplay, nxagentWindow(pWin), propertyX,
+ typeX, format, PropModeAppend, (void*) data, n);
+
+ nUnits -= n;
+
+ data = (char *) data + n * (format >> 3);
+ }
+ }
+ else
+ {
+ #ifdef WARNING
+ fprintf(stderr, "nxagentExportProperty: WARNING! "
+ "Property [%lu] too long.\n", propertyX);
+ #endif
+
+ goto nxagentExportPropertyError;
+ }
+
nxagentAddPropertyToList(propertyX, pWin);
}
}
@@ -740,6 +792,8 @@ int nxagentExportProperty(pWin, property, type, format, mode, nUnits, value)
#endif
}
+ nxagentExportPropertyError:
+
if (freeMem)
{
xfree(output);