Commit Graph

98 Commits

Author SHA1 Message Date
Alan Coopersmith 23e83724df Fix spelling/wording issues
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>
2020-07-05 13:07:33 -07:00
Eric Anholt e1ccd0fa0e dix: Fix a warning about GetTimeInMillis return value in XFont2.
Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2018-05-08 11:59:28 -04:00
Keith Packard 9d15912aa4 Remove fd_set from Block/Wakeup handler API
This removes the last uses of fd_set from the server interfaces
outside of the OS layer itself.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2016-07-18 15:27:51 -04:00
Keith Packard 05a793f5b3 dix: Switch to the libXfont2 API (v2)
This new libXfont API eliminates exposing internal X server symbols to
the font library, replacing those with a struct full of the entire API
needed to use that library.

v2: Use libXfont2 instead of libXfont_2

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2016-07-18 15:25:59 -04:00
Keith Packard 91ea0965dd dix: Move InitFonts up above screen initialization
Font initialization was split into two stages, the first was to set up
font privates with a call to ResetFontPrivateIndex, then much later
the call to InitFonts to set up all of the FPEs. Doing the full font
initialization before initializing the video drivers means that we can
move the call to ResetFontPrivateIndex inside InitFonts.

Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2015-12-01 13:55:11 -05:00
Keith Packard f9a04d19ae fonts: Continue when font calls return Suspended more than once
Patch 3ab6cd31cb fixed Xinerama
interactions with font servers by not putting clients to sleep
multiple times. However, it introduced additional changes dealing with
libXfont routine returning Suspended more than once for the same
request. This additional change was to abandon processing of the
current request and free the closure data by jumping to
'xinerama_sleep' in each of the functions.

Font library functions shouldn't return Suspended more than once,
except for ListFontsWithInfo, which produces multiple replies, and
thus ends up returning Suspended many times during processing.

With the jump to xinerama_sleep occurring after the first reply was
processed, the closure for the request was freed and future calls into
the ListFontsWithInfo callback resulted in dereferencing freed
memory.

This patch removes the added branches, reverting the code to its
previous behaviour, which permitted multiple Suspended returns and
simply waited for the client to be signaled again so that the callback
could continue processing the request.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2015-10-19 13:41:27 -04:00
Adam Jackson b51f7f8582 dix: Unexport various implementation details
Acked-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Adam Jackson <ajax@redhat.com>
2015-07-08 16:40:57 -04:00
Alan Coopersmith b9e665c8b2 Convert dix/* to new *allocarray functions
v2: remove now useless parentheses

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
2015-04-21 16:57:08 -07:00
Peter Hutterer 732fd7e571 Drop trailing whitespaces
sed -i "s/[ ]\+$//g" **/*.(c|h)

happy reviewing...
git diff -w is an empty diff.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-11-12 10:25:00 +10:00
Jasper St. Pierre ea15f8b4c9 dixfonts: Turn a missing directory ErrorF into a DebugF
On systems without these directories, we don't need to be complaining
loudly.

Reviewed-by: Kristian Hoegsberg <krh@bitplanet.net>

Signed-off-by: Keith Packard <keithp@keithp.com>
2014-04-21 15:01:02 -07:00
Alan Coopersmith e6733ae91b On realloc failure, free font_path_string instead of leaking it
Flagged by cppcheck 1.62:
[dix/dixfonts.c:1792]: (error) Common realloc mistake:
 'font_path_string' nulled but not freed upon failure

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Keith Packard <keithp@keithp.com>
2014-01-29 15:22:19 -08:00
Keith Packard 60014a4a98 Replace 'pointer' type with 'void *'
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>
2014-01-12 10:24:11 -08:00
Keith Packard d89b42bda4 Clean up warnings in DIX
As usual, mostly const char changes. However, filter_device_events had
a potentially uninitialized value, 'raw', which I added a bunch of
checks for. I suspect most of those are 'can't happen', but it's hard
to see that inside the function.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2014-01-12 10:14:49 -08:00
Alan Coopersmith 73b2660d72 Avoid use-after-free in dix/dixfonts.c: doImageText() [CVE-2013-4396]
Save a pointer to the passed in closure structure before copying it
and overwriting the *c pointer to point to our copy instead of the
original.  If we hit an error, once we free(c), reset c to point to
the original structure before jumping to the cleanup code that
references *c.

Since one of the errors being checked for is whether the server was
able to malloc(c->nChars * itemSize), the client can potentially pass
a number of characters chosen to cause the malloc to fail and the
error path to be taken, resulting in the read from freed memory.

Since the memory is accessed almost immediately afterwards, and the
X server is mostly single threaded, the odds of the free memory having
invalid contents are low with most malloc implementations when not using
memory debugging features, but some allocators will definitely overwrite
the memory there, leading to a likely crash.

Reported-by: Pedro Ribeiro <pedrib@gmail.com>
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Julien Cristau <jcristau@debian.org>
2013-10-14 17:56:44 -07:00
Yaakov Selkowitz 1aa783754e dix: fix redundant redeclaration warnings in dixfont
These functions are already declared in <X11/fonts/fontproto.h>.
Redeclaring them just for _X_EXPORT causes tons of warnings throughout
xserver, but they need to be declared somewhere to be picked up by
sdksyms.sh.  Doing so in a private header limits the warnings to
sdksyms.c; fixing those as well would require changes to fontsproto.

Signed-off-by: Yaakov Selkowitz <yselkowitz@users.sourceforge.net>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-11-05 13:24:59 -06:00
Alan Coopersmith d792ac125a Use C99 designated initializers in dix Replies
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-09 19:58:29 -07:00
Alan Coopersmith 789d64e19a Remove unneccesary casts from WriteToClient calls
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-07-09 19:12:56 -07:00
Alan Coopersmith a00066d291 Add dixGetGlyphs to replace GetGlyphs from libXfont to simplify linking
No other Xfont consumer used it, and this saves us from having to link
callers against libXfont for one simple function when doing
-no-undefined symbols builds.

The function is given a new name to avoid clashing with existing libXfont
binaries, but a #define is provided to preserve the API so we don't have
to fix all the callers at the same time.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Yaakov Selkowitz <yselkowitz@users.sourceforge.net>
2012-07-02 10:09:08 -07:00
Keith Packard 9838b7032e Introduce a consistent coding style
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>
2012-03-21 13:54:42 -07:00
Alan Hourihane 7a33c5b934 dixfonts: Don't overwrite local c variable until new_closure is safely initialized.
Signed-off-by: Alan Hourihane <alanh@vmware.com>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
2011-10-04 19:43:52 -07:00
Tiago Vignatti 12e46e8373 dix: fix memory leak in SetDefaultFontPath
Signed-off-by: Tiago Vignatti <tiago.vignatti@nokia.com>
Reviewed-by: Nicolas Peninguy <nico@lostgeeks.org>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-04-04 15:41:13 +03:00
Tiago Vignatti 49051355d4 dix: remove unused macro
Signed-off-by: Tiago Vignatti <tiago.vignatti@nokia.com>
Reviewed-by: Nicolas Peninguy <nico@lostgeeks.org>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-04-04 15:41:13 +03:00
Tiago Vignatti f1a80e1268 dix: remove unused debug code
Signed-off-by: Tiago Vignatti <tiago.vignatti@nokia.com>
Reviewed-by: Mikhail Gusarov <dottedmag@dottedmag.net>
Reviewed-by: Nicolas Peninguy <nico@lostgeeks.org>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-04-04 15:41:13 +03:00
Adam Jackson 7a9062f2f0 fonts: Fix typo in async ListFonts logic
This was introduced in 3ab6cd31cb.  Mea
culpa.  This logic is still incorrect [1], but at least it's less
incorrect.

[1] - https://bugzilla.redhat.com/658587

Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
Signed-off-by: Adam Jackson <ajax@redhat.com>
2010-12-20 12:12:09 -05:00
Alan Coopersmith 03e8bfa1d1 Convert existing Xprintf style calls to asprintf style
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
Reviewed-by: Mikhail Gusarov <dottedmag@dottedmag.net>
2010-12-07 11:10:35 -08:00
Jamey Sharp 2051e0f371 dixfonts: Deobfuscate GC ops calls.
Signed-off-by: Jamey Sharp <jamey@minilop.net>
Reviewed-by: Alex Deucher <alexdeucher@gmail.com>
2010-09-13 15:55:17 -07:00
Adam Jackson 3ab6cd31cb fonts: Fix refcounting for asynchronous font operations (#3040)
When doing Xinerama, we'll dispatch font ops across all backend screens.
If using a font server (such that some operations can sleep), we'll put
the client to sleep once for each screen, but only wake up once, because
we're trying to keep track of the sleep count in _each_ screen's
closure.

Instead, just ask the core whether the client is already asleep.

Signed-off-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2010-08-09 21:31:41 -07:00
Tiago Vignatti 75536ee805 dix: use one single function to register fpe fonts
X server doesn't need to understand fpe internals, so use
register_fpe_functions from libXfont.

It's required to get new version of libXfont, therefore adjust it to be passed
to autoconf.

Signed-off-by: Tiago Vignatti <tiago.vignatti@nokia.com>
Reviewed-by: Mikhail Gusarov <dottedmag@dottedmag.net>
Reviewed-by: Alex Deucher <alexdeucher@gmail.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2010-06-24 13:55:28 -07:00
Mikhail Gusarov 6592db6bb5 Get rid of xstrdup when argument is definitely non-NULL
Replace xstrdup with strdup when either constant string is
being duplicated or argument is guarded by conditionals and
obviously can't be NULL

Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2010-06-11 19:04:23 +07:00
Mikhail Gusarov 7287ef9e6c Remove unnecessary parentheses around return values in functions
This patch was generated by the following Perl code:

perl -i -pe 's/([^_])return\s*\(\s*([^(]+?)\s*\)s*;(\s+(\n))?/$1return $2;$4/g;'

Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net>
Reviewed-by: Jamey Sharp <jamey@minilop.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
Signed-off-by: Keith Packard <keithp@keithp.com>
2010-06-10 06:42:42 -07:00
Mikhail Gusarov 0a4d8cbdcd Remove more superfluous if(p) checks around free(p)
This patch has been generated by the following Coccinelle semantic patch:

@@
expression E;
@@

-if(E) { free(E); }
+free(E);

Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net>
Reviewed-by: Julien Cristau <jcristau@debian.org>
Reviewed-by: Fernando Carrijo <fcarrijo@yahoo.com.br>
Reviewed-by: Matt Turner <mattst88@gmail.com>
2010-06-06 20:27:18 +07:00
Mikhail Gusarov 5a0fc0ad21 Replace deprecated bzero with memset
Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net>
Reviewed-by: Marcin Baczyński <marbacz@gmail.com>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
2010-06-06 15:07:27 +07:00
Jamey Sharp d8cbcbc01d doPolyText: forget about FontChange's XID after looking up pFont.
As of e2929db7b7, doPolyText uses pFont
consistently rather than looking it up again from the saved XID.

clang noticed that "oldfid = fid" could run when fid hadn't been
initialized yet.

Signed-off-by: Jamey Sharp <jamey@minilop.net>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
Tested-by: Jeremy Huddleston <jeremyhu@apple.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2010-05-21 12:48:16 -07:00
Jamey Sharp e291c56182 Return an appropriately-typed error from dixLookupResourceByType.
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-19 12:32:48 -07:00
Jamey Sharp 6a84cd9434 Replace dixChangeGC with calls directly to the right variant.
Signed-off-by: Jamey Sharp <jamey@minilop.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2010-05-13 17:14:07 -07:00
Jamey Sharp e2929db7b7 dixChangeGC callers: Use ChangeGCVal instead of XID almost everywhere.
The exceptions are ProcChangeGC and CreateGC.

Signed-off-by: Jamey Sharp <jamey@minilop.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2010-05-13 17:13:48 -07:00
Jamey Sharp 04bad1b8a1 Kill ChangeGC in favor of dixChangeGC.
This doesn't change any behavior, but it isn't clear whether NullClient
is correct in all cases. As ajax says,

> For most of these changes, I think it's correct to use NullClient,
> since they are server-initiated changes and should not fail for (eg)
> xace reasons. ... At any rate, you're certainly not changing any
> semantics by leaving them all as NullClient, so this patch can't be
> more wrong than before.

The call in CreateGC is particularly questionable.

Signed-off-by: Jamey Sharp <jamey@minilop.net>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2010-05-12 18:10:01 -07:00
Jamey Sharp afcbbd6dfe doPolyText needs UseAccess to each font, not ReadAccess.
In commit 42d6112ec2, Eamon changed
dixChangeGC to require DixUseAccess on any GCFont XID. I think
doPolyText needs to require the same level of access. Otherwise
dixChangeGC could fail when it does the same lookup, which doPolyText
doesn't check for.

Signed-off-by: Jamey Sharp <jamey@minilop.net>
Cc: Eamon Walsh <ewalsh@tycho.nsa.gov>
Reviewed-by: Eamon Walsh <ewalsh@tycho.nsa.gov>
2010-05-12 18:00:29 -07:00
Jamey Sharp 21ceae9002 SetFontPath: set client->errorValue on failure.
Previously the callers were only setting errorValue on Success, when
it's ignored, and leaving it alone on failure, when it's sent to the
client.

Since SetFontPath takes the ClientPtr, let it set client->errorValue
instead of letting the callers continue to get it wrong.

Signed-off-by: Jamey Sharp <jamey@minilop.net>
Reviewed-by: Julien Cristau <jcristau@debian.org>
Signed-off-by: Keith Packard <keithp@keithp.com>
2010-05-12 12:08:38 -07:00
Mikhail Gusarov 4d55c8c4ff Use lowercase variant of XNFalloc and Xstrdup
Using one variant of function/macro makes it easier to fix the code
later.

Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-05-13 00:22:37 +07:00
Mikhail Gusarov 3f3ff971ec Replace X-allocation functions with their C89 counterparts
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-05-13 00:22:37 +07:00
Yaakov Selkowitz abf4e0b7e3 New header for XF86Bigfont server functions
Xext/xf86bigfont.c contains three non-static functions which are called
elsewhere in the server.  This creates a new header containing these
declarations in order to fix several warnings:

xf86bigfont.c:285: warning: no previous prototype for `XF86BigfontFreeFontShm'
dixfonts.c:502: warning: implicit declaration of function `XF86BigfontFreeFontS$
dixfonts.c:502: warning: nested extern declaration of `XF86BigfontFreeFontShm'
log.c:436: warning: implicit declaration of function `XF86BigfontCleanup'
log.c:436: warning: nested extern declaration of `XF86BigfontCleanup'

Signed-off-by: Yaakov Selkowitz <yselkowitz@users.sourceforge.net>
Reviewed-by: Julien Cristau <jcristau@debian.org>
2010-03-22 00:48:04 -05:00
Kim Woelders 4970666827 dix: Fix potential memory corruption in doListFontsWithInfo.
Signed-off-by: Kim Woelders <kim@woelders.dk>
Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-09-30 10:21:29 +10:00
Rémi Cardona f56cbe1ef2 dix: append "built-ins" to the font path in SetDefaultFontPath
49b93df8a3 made the hard dependency on
a "fixed" font go away but only Xorg could use the built-ins fonts by
default.

With this commit, all DDXs get "built-ins" appended to their FontPath, not
just Xorg.

Tested with Xorg, Xvfb and Xnest.

Signed-off-by: Rémi Cardona <remi@gentoo.org>
Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Tested-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-09-16 11:44:08 +10:00
Peter Hutterer 2d35ea8d95 dix: switch to byte-counting functions.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-07-14 10:05:54 +10:00
Eamon Walsh 57aff88c7d Fix most remaining deprecated resource lookups.
Callsites updated to use dixLookupResourceBy{Type,Class}.
TODO: Audit access modes to make sure they reflect the usage.
2009-04-29 01:04:37 -04:00
Peter Hutterer 6093d3eb1d dix: fix two compiler warnings (old-style function definition).
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-03-03 07:07:30 +10:00
Peter Åstrand ddb8d8945d xserver: Avoid sending uninitialized padding data over the network
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-02-16 13:28:38 +10:00
Benjamin Close d62c085f36 dix: Remove includes which are not actually used directly
Signed-off-by: Benjamin Close <Benjamin.Close@clearchain.com>
Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Daniel Stone <daniel@fooishbar.org>
2009-02-13 17:23:43 +10:30
Adam Jackson 132b464d73 Remove a bunch of useless casts.
We've had void * for twenty years now people let's try to act like we
know how it works.
2009-01-22 02:11:16 -05:00