summaryrefslogtreecommitdiff
path: root/Xext/saver.c
AgeCommit message (Collapse)AuthorFilesLines
2024-04-30include: move private definitions out of extinit.hEnrico Weigelt, metux IT consult1-1/+1
Public server module API shouldn't be clobbered with private definitions, thus move them out to extinit_priv.h. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net> Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1289>
2024-04-15rename remaining RT_* defines to X11_RESTYPE_*Enrico Weigelt, metux IT consult1-6/+6
Since we already had to rename some of them, in order to fix name clashes on win32, it's now time to rename all the remaining ones. The old ones are still present as define's to the new ones, just for backwards compatibility. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net> Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1355>
2024-04-15prevent name clash on Windows w/ RT_* definesEnrico Weigelt, metux IT consult1-5/+5
Windows' native headers using some our RT_* define's names for other things. Since the naming isn't very nice anyways, introducing some new ones (X11_RESTYPE_NONE, X11_RESTYPE_FONT, X11_RESTYPE_CURSOR) and define the old ones as an alias to them, in case some out-of-tree code still uses them. With thins change, we don't need to be so extremely careful about include ordering and have explicit #undef's in order to prevent name clashes on Win32 targets. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net> Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1355>
2024-04-15dix: unexport some lookup functionsEnrico Weigelt, metux IT consult1-4/+5
These aren't used by any drivers, so no need to export them. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net> Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1380>
2022-12-14Xext: free the screen saver resource when replacing itPeter Hutterer1-1/+1
This fixes a use-after-free bug: When a client first calls ScreenSaverSetAttributes(), a struct ScreenSaverAttrRec is allocated and added to the client's resources. When the same client calls ScreenSaverSetAttributes() again, a new struct ScreenSaverAttrRec is allocated, replacing the old struct. The old struct was freed but not removed from the clients resources. Later, when the client is destroyed the resource system invokes ScreenSaverFreeAttr and attempts to clean up the already freed struct. Fix this by letting the resource system free the old attrs instead. CVE-2022-46343, ZDI-CAN 19404 This vulnerability was discovered by: Jan-Niklas Sohn working with Trend Micro Zero Day Initiative Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Acked-by: Olivier Fourdan <ofourdan@redhat.com>
2021-12-14Xext: Fix out of bounds access in SProcScreenSaverSuspend()Povilas Kanapickas1-1/+1
ZDI-CAN-14951, CVE-2021-4010 This vulnerability was discovered and the fix was suggested by: Jan-Niklas Sohn working with Trend Micro Zero Day Initiative Signed-off-by: Povilas Kanapickas <povilas@radix.lt>
2020-07-05Fix spelling/wording issuesAlan Coopersmith1-2/+2
Most (but not all) of these were found by using codespell --builtin clear,rare,usage,informal,code,names but not everything reported by that was fixed. Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2018-03-14Xext/saver: Swap ScreenSaverSuspend 'suspend' field. Handle old XCB clients.Keith Packard1-2/+12
This field was defined as a Bool in the protocol headers and BOOL in xcb. Bool is not a valid type for protocol fields. It is defined as 'int' by Xdefs.h, which we expect to be 32-bits on all machines. The protocol headers and xcb have patches posted to switch to CARD32, which is at least well defined. This change adds the necessary byte swapping to handle other-endian clients with this 32-bit field, and then changes the request processing to compare all 32-bits against zero so that it works with both new and old clients. On MSB machines, Xlib will continue to work properly, but old XCB will not interoperate with the X server (either before or after this patch). Signed-off-by: Keith Packard <keithp@keithp.com> Reviewed-by: Mihai Moldovan <ionic@ionic.de> Reviewed-by: Adam Jackson <ajax@redhat.com>
2017-10-30Use ARRAY_SIZE all over the treeDaniel Martin1-4/+2
Roundhouse kick replacing the various (sizeof(foo)/sizeof(foo[0])) with the ARRAY_SIZE macro from dix.h when possible. A semantic patch for coccinelle has been used first. Additionally, a few macros have been inlined as they had only one or two users. Signed-off-by: Daniel Martin <consume.noise@gmail.com> Reviewed-by: Adam Jackson <ajax@redhat.com>
2017-10-10Unvalidated lengthsNathan Kidd1-0/+2
v2: Add overflow check and remove unnecessary check (Julien Cristau) This addresses: CVE-2017-12184 in XINERAMA CVE-2017-12185 in MIT-SCREEN-SAVER CVE-2017-12186 in X-Resource CVE-2017-12187 in RENDER Reviewed-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com> Reviewed-by: Julien Cristau <jcristau@debian.org> Signed-off-by: Nathan Kidd <nkidd@opentext.com> Signed-off-by: Julien Cristau <jcristau@debian.org>
2017-03-27dpms: Consolidate a bunch of stuff into Xext/dpms.cAdam Jackson1-0/+1
Most of this is a legacy of the old "extmod" design where you could load _some_ extensions dynamically but only if the server had been built with support for them in the first place. Note that since we now only initialize the DPMS extension if at least one screen supports it, we no longer need DPMSCapableFlag: if it would be false, we would never read its value. Signed-off-by: Adam Jackson <ajax@redhat.com> Reviewed-by: Eric Anholt <eric@anholt.net>
2017-03-01dispatch: Mark swapped dispatch as _X_COLDAdam Jackson1-8/+8
This touches everything that ends up in the Xorg binary; the big missing part is GLX since that's all generated code. Cuts about 14k from the binary on amd64. Signed-off-by: Adam Jackson <ajax@redhat.com> Reviewed-by: Eric Anholt <eric@anholt.net>
2016-04-29dix: Squash some new gcc6 warningsAdam Jackson1-1/+1
-Wlogical-op now tells us: devices.c:1685:23: warning: logical ‘and’ of equal expressions Reviewed-by: Julien Cristau <jcristau@debian.org> Signed-off-by: Adam Jackson <ajax@redhat.com>
2015-04-21Convert top level extensions to new *allocarray functionsAlan Coopersmith1-1/+1
v2: remove now useless parentheses Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Matt Turner <mattst88@gmail.com>
2014-07-29saver: Don't open-code IsMapInstalledAdam Jackson1-15/+1
Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Adam Jackson <ajax@redhat.com>
2014-01-12Clean up a few function prototypes to not place formals in /**/Keith Packard1-26/+14
This just removes the comment markers from around the formals in several function prototypes near where pointer -> void * changes were made. There are plenty more of these to fix. Signed-off-by: Keith Packard <keithp@keithp.com> Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2014-01-12Replace 'pointer' type with 'void *'Keith Packard1-20/+20
This lets us stop using the 'pointer' typedef in Xdefs.h as 'pointer' is used throughout the X server for other things, and having duplicate names generates compiler warnings. Signed-off-by: Keith Packard <keithp@keithp.com> Reviewed-by: Eric Anholt <eric@anholt.net>
2013-10-18dix: provide accessor methods for the last device event timePeter Hutterer1-4/+2
And now that we have the accessors, localize it. No functional changes, just preparing for a future change. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Adam Jackson <ajax@redhat.com> Reviewed-by: Keith Packard <keithp@keithp.com>
2013-05-15Abstract cursor refcountingPeter Hutterer1-4/+4
Too many callers relied on the refcnt being handled correctly. Use a simple wrapper to handle that case. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-12-05Fix formatting of address operatorsYaakov Selkowitz1-1/+1
The formatter confused address operators preceded by casts with bitwise-and expressions, placing spaces on either side of both. That syntax isn't used by ordinary address operators, however, so fix them for consistency. Signed-off-by: Yaakov Selkowitz <yselkowitz@users.sourceforge.net> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-11-29When resetting device idle time, reset XIAll(Master)Devices too (#56649)Peter Hutterer1-0/+2
When the screen saver is forcibly deactivated, the idle time counter is reset for all devices but not for the fake XIAllDevices and XIAllMasterDevices. XScreenSaverQueryInfo uses XIAlldevices to fill the "idle" field, thus returning the wrong value. Regression introduced in commit 6aef209ebc2e54f5465da505a780f7b4cc273ee0 Author: Peter Hutterer <peter.hutterer@who-t.net> Date: Mon Mar 12 13:51:02 2012 +1000 Change lastDeviceIdleTime to be per-device X.Org Bug 56649 <http://bugs.freedesktop.org/show_bug.cgi?id=56649> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Tested-by: Giacomo Perale <ghepeu@virgilio.it> Reviewed-by: Keith Packard <keithp@keithp.com>
2012-07-09Move extension initialisation prototypes into extinit.hDaniel Stone1-1/+1
Create extinit.h (and xf86Extensions.h, for Xorg-specific extensions) to hold all our extension initialisation prototypes, rather than duplicating them everywhere. Signed-off-by: Daniel Stone <daniel@fooishbar.org> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Keith Packard <keithp@keithp.com>
2012-07-09Replace INITARGS with voidTomas Carnecky1-1/+1
INITARGS was a hardcoded define to void. Since knowing the function signature for your extensions is kinda useful, just replace it with a hardcoded void, but leave the define there for API compatibility. Signed-off-by: Tomas Carnecky <tom@dbservice.com> Reviewed-by: Daniel Stone <daniel@fooishbar.org> Reviewed-by: Cyril Brulebois <kibi@debian.org> Reviewed-by: Jamey Sharp <jamey@minilop.net> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Keith Packard <keithp@keithp.com>
2012-07-09Use C99 designated initializers in extension EventsAlan Coopersmith1-11/+12
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Keith Packard <keithp@keithp.com> Tested-by: Daniel Stone <daniel@fooishbar.org>
2012-07-09Use C99 designated initializers in Xext RepliesAlan Coopersmith1-10/+14
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Keith Packard <keithp@keithp.com> Tested-by: Daniel Stone <daniel@fooishbar.org>
2012-07-09Remove unneccesary casts from WriteToClient callsAlan Coopersmith1-2/+2
Casting return to (void) was used to tell lint that you intended to ignore the return value, so it didn't warn you about it. Casting the third argument to (char *) was used as the most generic pointer type in the days before compilers supported C89 (void *) (except for a couple places it's used for byte-sized pointer math). Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Keith Packard <keithp@keithp.com> Tested-by: Daniel Stone <daniel@fooishbar.org>
2012-03-22Change lastDeviceIdleTime to be per-devicePeter Hutterer1-2/+5
Preparation work for per-device idle counters. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com> Reviewed-by: Jamey Sharp <jamey@minilop.net> Reviewed-by: James Jones <jajones@nvidia.com>
2012-03-21Introduce a consistent coding styleKeith Packard1-876/+790
This is strictly the application of the script 'x-indent-all.sh' from util/modular. Compared to the patch that Daniel posted in January, I've added a few indent flags: -bap -psl -T PrivatePtr -T pmWait -T _XFUNCPROTOBEGIN -T _XFUNCPROTOEND -T _X_EXPORT The typedefs were needed to make the output of sdksyms.sh match the previous output, otherwise, the code is formatted badly enough that sdksyms.sh generates incorrect output. The generated code was compared with the previous version and found to be essentially identical -- "assert" line numbers and BUILD_TIME were the only differences found. The comparison was done with this script: dir1=$1 dir2=$2 for dir in $dir1 $dir2; do (cd $dir && find . -name '*.o' | while read file; do dir=`dirname $file` base=`basename $file .o` dump=$dir/$base.dump objdump -d $file > $dump done) done find $dir1 -name '*.dump' | while read dump; do otherdump=`echo $dump | sed "s;$dir1;$dir2;"` diff -u $dump $otherdump done Signed-off-by: Keith Packard <keithp@keithp.com> Acked-by: Daniel Stone <daniel@fooishbar.org> Acked-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2011-12-06xext: don't free uninitialised pointer when malloc fails. (v2)Dave Airlie1-2/+1
Initialise the pAttr->values to values so if the values allocation fails it just ends up as free(NULL). Pointed out by coverity. v2: use Alan's suggestion. Signed-off-by: Dave Airlie <airlied@redhat.com> Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
2011-09-21Use correct swap{l,s} (or none at all for CARD8)Matt Turner1-1/+0
Swapping the wrong size was never caught because swap{l,s} are macros. It's clear in the case of Xext/xres.c, that the author believed client_major/minor to be CARD16 from looking at the code in the first hunk. v2: dmx.c fixes from Keith. Reviewed-by: Peter Harris <pharris@opentext.com> Signed-off-by: Matt Turner <mattst88@gmail.com>
2011-09-21Use internal temp variable for swap macrosMatt Turner1-41/+28
Also, fix whitespace, mainly around swaps(&rep.sequenceNumber) Reviewed-by: Peter Harris <pharris@opentext.com> Signed-off-by: Matt Turner <mattst88@gmail.com>
2010-09-28xserver: delete pervasively use of DISPATCH_PROCTiago Vignatti1-55/+33
Some functions had to be moved around due some missing static definitions. Another minor clean up like inexistent function declarations and etc were made also. Part of this patch was cooked using: sed -i -e '/static DISPATCH_PROC*.*;/d' `git ls-files` Signed-off-by: Tiago Vignatti <tiago.vignatti@nokia.com> Reviewed-by: Mikhail Gusarov <dottedmag@dottedmag.net>
2010-06-05Change the devPrivates API to require dixRegisterPrivateKeyKeith Packard1-2/+5
This patch only changes the API, not the implementation of the devPrivates infrastructure. This will permit a new devPrivates implementation to be layed into the server without requiring simultaneous changes in every devPrivates user. Signed-off-by: Keith Packard <keithp@keithp.com> Tested-by: Tiago Vignatti <tiago.vignatti@nokia.com>
2010-06-03Move each screen's root-window pointer into ScreenRec.Jamey Sharp1-3/+3
Many references to the WindowTable array already had the corresponding screen pointer handy, which meant they usually looked like "WindowTable[pScreen->myNum]". Adding a field to ScreenRec instead of keeping this information in a parallel array simplifies those expressions, and eliminates a MAXSCREENS-sized array. Since dix uses this data, a screen private entry isn't appropriate. xf86-video-dummy currently uses WindowTable, so it needs to be updated to reflect this change. Signed-off-by: Jamey Sharp <jamey@minilop.net> Reviewed-by: Tiago Vignatti <tiago.vignatti@nokia.com> Tested-by: Tiago Vignatti <tiago.vignatti@nokia.com> (i686 GNU/Linux)
2010-06-03Move each screen's screensaver data into ScreenRec.Jamey Sharp1-6/+6
Most references to the savedScreenInfo array already had the corresponding screen pointer handy, which meant they usually looked like "savedScreenInfo[pScreen->myNum]". Adding a field to ScreenRec instead of keeping this information in a parallel array simplifies those expressions, and eliminates a MAXSCREENS-sized array. Since dix uses this data, a screen private entry isn't appropriate. Signed-off-by: Jamey Sharp <jamey@minilop.net> Reviewed-by: Tiago Vignatti <tiago.vignatti@nokia.com> Tested-by: Tiago Vignatti <tiago.vignatti@nokia.com> (i686 GNU/Linux)
2010-05-19Add typed resource-lookup errors for non-core resource types.Jamey Sharp1-3/+3
Signed-off-by: Jamey Sharp <jamey@minilop.net> Reviewed-by: Adam Jackson <ajax@redhat.com>
2010-05-19Return an appropriately-typed error from dixLookupResourceByType.Jamey Sharp1-4/+0
Rather than always returning BadValue, associate an error status like BadWindow with a resource type like RT_WINDOW, and return the appropriate one for the requested type. This patch only touches the core protocol resource types. Others still return BadValue and need to be mapped appropriately. dixLookupResourceByType can now return BadImplementation, if the caller asked for a resource type that has not been allocated in the server. Signed-off-by: Jamey Sharp <jamey@minilop.net> Reviewed-by: Adam Jackson <ajax@redhat.com>
2010-05-19Set event sequence number in WriteEventsToClient instead of at callers.Jamey Sharp1-4/+1
TryClientEvents already did this; this commit just moves the assignment one level down so that no event source has to worry about sequence numbers. ...No event source, that is, except XKB, which inexplicably calls WriteToClient directly for several events. Signed-off-by: Jamey Sharp <jamey@minilop.net> Reviewed-by: Julien Cristau <jcristau@debian.org> Reviewed-by: Adam Jackson <ajax@redhat.com>
2010-05-19Make WriteEventsToClient/WriteToClient no-op on fake or dead clients.Jamey Sharp1-2/+0
This matches the test in TryClientEvents, and is a superset of tests done by the callers of these functions. The consequence of forgetting these tests is a server crash, so they're always desirable. In my opinion, it's better to not require the callers to remember to do these checks. For callers that don't do very much work before calling WriteToClient or WriteEventsToClient, I've removed the redundant checks. hw/xquartz/xpr/appledri.c has an interesting case: While its check for "client == NULL" appears redundant with the test in WriteEventsToClient, it dereferences client to get the sequence number. Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=27497 Signed-off-by: Jamey Sharp <jamey@minilop.net> Cc: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: Julien Cristau <jcristau@debian.org> Reviewed-by: Adam Jackson <ajax@redhat.com>
2010-05-13Eliminate boilerplate around client->noClientException.Jamey Sharp1-3/+3
Just let Dispatch() check for a noClientException, rather than making every single dispatch procedure take care of it. Signed-off-by: Jamey Sharp <jamey@minilop.net> Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2010-05-13Replace X-allocation functions with their C89 counterpartsMikhail Gusarov1-14/+14
The only remaining X-functions used in server are XNF*, the rest is converted to plain alloc/calloc/realloc/free/strdup. X* functions are still exported from server and x* macros are still defined in header file, so both ABI and API are not affected by this change. Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-03-22Xext: Fix cursor reference counting hazard.Michel Dänzer1-1/+1
Make sure the reference count of the new cursor is increased before the old one is decreased, otherwise bad things will happen if they're one and the same and the reference count is 1 initially. Not sure this can actually happen here, but better safe than sorry. Signed-off-by: Michel Dänzer <daenzer@vmware.com> Reviewed-by: Roland Scheidegger <sroland@vmware.com> Signed-off-by: Keith Packard <keithp@keithp.com>
2009-12-18Add type name argument to CreateNewResourceTypeAlan Coopersmith1-7/+5
Convert all calls of CreateNewResourceType to pass name argument Breaks DIX ABI. ABI versions bumped: Signed-off-by: Alan Coopersmith <alan.coopersmith@sun.com> Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Keith Packard <keithp@keithp.com>
2009-12-18Ensure all resource types created have names registeredAlan Coopersmith1-0/+4
Calls RegisterResourceName to record the type name for use by X-Resource, XACE/SELinux/XTsol, and DTrace. Signed-off-by: Alan Coopersmith <alan.coopersmith@sun.com> Reviewed-by: Keith Packard <keithp@keithp.com>
2009-09-21input: define server-supported protocol versions in one single file.Peter Hutterer1-2/+3
include/protocol-versions.h specifies each extension version as supported by the server and sent back on the wire to the client. This fixes up several issues with the server potentially reporting a higher version of the protocol if recompiled against a newer version of the protocol. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Acked-by: Rémi Cardona <remi@gentoo.org> Acked-by: Julien Cristau <jcristau@debian.org>
2009-07-15Update to xextproto 7.0.99.1.Peter Hutterer1-2/+1
xextproto had Xlib client headers moved into libXext. Protocol header files are named fooproto.h, header files with constants foo.h or fooconst.h where foo.h was already in use for client-side headers.
2009-07-14Xext: switch to byte counting functionsPeter Hutterer1-2/+2
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-04-29Fix most remaining deprecated resource lookups.Eamon Walsh1-21/+33
Callsites updated to use dixLookupResourceBy{Type,Class}. TODO: Audit access modes to make sure they reflect the usage.
2009-03-09Replace dixLookupResource by dixLookupResourceBy{Type,Class}Keith Packard1-4/+4
dixLookupResource attempted to automatically detect whether the caller wanted a lookup by-type or by-class, unfortunately, it guessed wrong for RT_NONE. Instead of trying to make the guess better, this patch just reverts the unification and creates separate functions for each operation.
2009-02-03Xext: rename saver's EventType to SaverEventType.Peter Hutterer1-5/+5
Avoid namespace clashing with the internal events. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>