Commit Graph

1691 Commits (1a138abf7580868cd42b1ff4b025b3ff5bf1471a)

Author SHA1 Message Date
Ran Benita 1a138abf75 Update NEWS
Signed-off-by: Ran Benita <ran234@gmail.com>
2018-08-03 13:55:17 +03:00
Ran Benita 1f3666915b
Merge pull request #66 from whot/master
Coverity fixes (one real bug)
2018-08-01 12:25:18 +03:00
Peter Hutterer c81682975d action: make a note that we may not null-terminate private strings
Coverity complains that a 7-byte string may not be null-terminated when copied
into act->data (size 7). This is fine, make a note of it.

All the strings in xkeyboard-config only use 6 bytes + null terminator so this
won't be an issue. The server (the only user of these) uses an 8-byte array
and forcibly null-terminates the string, see XkbDDXPrivate().

Everything else treats it as byte-array size 7 anyway so whether it's
null-terminated doesn't matter.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-08-01 18:50:38 +10:00
Peter Hutterer c1e5ac16e7 xkbcomp: fix pointer value for FreeStmt
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-08-01 13:50:38 +10:00
Peter Hutterer badb428e63 keycodes: don't try to copy zero key aliases
Move the aliases copy to within the (num_key_aliases > 0) block.

Passing info->aliases into this fuction with invalid aliases will
cause log messages but num_key_aliases stays on 0. The key_aliases array
is never allocated and remains NULL. We then loop through the aliases, causing
a null-pointer dereference.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-08-01 13:50:38 +10:00
Peter Hutterer 9045b03598 text: init the target buffer to zero
There's a (theoretical?) path where we might end up strcpy() buf without ever
writing to it. This happens if the mask is nonzero but specifies a modifier
larger than the one in the xkb_mod_set.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-08-01 13:50:38 +10:00
Ran Benita 842e4351c2 compose: fix infinite loop in parser on some inputs
The parser would enter an infinite loop if an unterminated keysym
literal occurs at EOF.

Found with the afl fuzzer.

Signed-off-by: Ran Benita <ran234@gmail.com>
2018-07-30 10:35:10 +03:00
Ran Benita 917636b1d0 xkbcomp: fix crash when parsing an xkb_geometry section
xkb_geometry sections are ignored; previously the had done so by
returning NULL for the section's XkbFile, however some sections of the
code do not expect this. Instead, create an XkbFile for it, it will
never be processes and discarded later.

Caught with the afl fuzzer.

Signed-off-by: Ran Benita <ran234@gmail.com>
2018-07-30 10:35:10 +03:00
Ran Benita e3cacae7b1 xkbcomp: fix crashes in the parser when geometry tokens appear
In the XKB format, floats and various keywords can only be used in the
xkb_geometry section. xkbcommon removed support xkb_geometry, but still
parses it for backward compatibility. As part of ignoring it, the float
AST node and various keywords were removed, and instead NULL was
returned by their parsing actions. However, the rest of the code does
not handle NULLs, and so when they appear crashes usually ensue.

To fix this, restore the float AST node and the ignored keywords. None
of the evaluating code expects them, so nice error are displayed.

Caught with the afl fuzzer.

Signed-off-by: Ran Benita <ran234@gmail.com>
2018-07-30 10:35:10 +03:00
Ran Benita 1f9d1248c0 xkbcomp: fix stack overflow when evaluating boolean negation
The expression evaluator would go into an infinite recursion when
evaluating something like this as a boolean: `!True`. Instead of
recursing to just `True` and negating, it recursed to `!True` itself
again.

Bug inherited from xkbcomp.

Caught with the afl fuzzer.

Signed-off-by: Ran Benita <ran234@gmail.com>
2018-07-30 10:35:10 +03:00
Ran Benita 2cb5c2a3f3 Add fuzzing infrastructure
Though text formats aren't exactly fuzzer's strong suit, fuzzers can
catch many surface-level bugs.

The fuzz/ directory contains target programs, testcases and dictionaries
to drive the afl fuzzer.

This commit adds a fuzzer for the XKB keymap text format and the Compose
text format. On my slow machine, using a single core, a full cycle of
the XKB fuzzer takes 5 hours. For Compose, it takes a few minutes.

Fuzzing for the other file formats (rules files mostly) will be added
later.

To do some fuzzing, run `./fuzz/fuzz.sh`.

Signed-off-by: Ran Benita <ran234@gmail.com>
2018-07-30 10:35:10 +03:00
Ran Benita a54cfe087a
Merge pull request #65 from heftig/pc-fix2
meson: Fix xkbcommon-x11.pc Requires versioning
2018-07-17 19:06:12 +03:00
Jan Alexander Steffens (heftig) 83a553a009 meson: Fix xkbcommon-x11.pc Requires versioning
Old meson expects an array with one dependency per element. Providing a
string containing multiple deps results in only the first dep getting
its whitespace properly applied. As a result, the output was:

    Requires.private: xcb >= 1.10 xcb-xkb>=1.10

And downstream projects failed to find a package named 'xcb-xkb>=1.10'.

Specifying an array of versioned deps results in correct output:

    Requires.private: xcb >= 1.10, xcb-xkb >= 1.10

Fixes #64.

Signed-off-by: Jan Alexander Steffens (heftig) <jan.steffens@gmail.com>
2018-07-17 17:31:55 +02:00
Jan Alexander Steffens (heftig) a3c907d389 meson: Fix xkbcommon-x11.pc Requires
The meson-generated pkgconfig file was missing Requires and
Requires.private.

[ran: adjust for older Meson versions.]

Signed-off-by: Jan Alexander Steffens (heftig) <jan.steffens@gmail.com>
Signed-off-by: Ran Benita <ran234@gmail.com>
2018-07-17 09:30:43 +03:00
Ran Benita c8e17eede5 bench: simplify the bench helpers
Trim the API a bit.

Also, just always use gettimeofday(), which is portable. Hopefully the
system clock doesn't change while a benchmark is running.

Signed-off-by: Ran Benita <ran234@gmail.com>
2018-07-05 18:29:39 +03:00
Ran Benita 110d17c6be travis: pin meson to an older version so it works with Python 3.4
The CI image only has Python 3.4. It's a bit of a hassle to change this,
so let's pin meson to the version before they bumped their requirement
instead.

I suppose it's not that bad in that it will guarantee compatibility with
older meson over time.

Signed-off-by: Ran Benita <ran234@gmail.com>
2018-06-23 23:17:07 +03:00
Ran Benita 5cee660f69 keysym-utf: reject out-of-range Unicode codepoints in xkb_keysym_to_utf{8,32}
It used to be UTF-8 was defined for inputs > 0x10FFFF, but nowadays
that's the maximum and a codepoint is encoded up to 4 bytes, not 6.

Fixes: https://github.com/xkbcommon/libxkbcommon/issues/58
Fixes: https://github.com/xkbcommon/libxkbcommon/issues/59
Reported-by: @andrecbarros
Signed-off-by: Ran Benita <ran234@gmail.com>
2018-06-23 22:53:42 +03:00
Ran Benita b63196e91e keysym-utf: replace the Unicode characters for leftanglebracket and rightanglebracket
Looking at leftanglebracket

- The standard[1] does not specify any Unicode value for it.

- The keysym list keysymdef.h in x11proto[2] says U+27E9 MATHEMATICAL
  RIGHT ANGLE BRACKET in a comment.

- The keysym->unicode list in xkbcommon which comes from [3] has U+2329
  LEFT-POINTING ANGLE BRACKET.

- The keysym->unicode list in Xlib[4] has U+2039 SINGLE LEFT-POINTING
  ANGLE QUOTATION MARK.

[1] https://www.x.org/releases/X11R7.7/doc/xproto/x11protocol.html#Legacy_KEYSYMs
[2] https://cgit.freedesktop.org/xorg/proto/x11proto/tree/keysymdef.h
[3] https://www.cl.cam.ac.uk/%7Emgk25/ucs/keysym2ucs.c
[4] https://cgit.freedesktop.org/xorg/lib/libX11/tree/src/xlibi18n/imKStoUCS.c

The symbols we are using, {LEFT,RIGHT}-POINTING ANGLE BRACKET, are
deprecated according to Unicode[5]:

    These characters are deprecated and are strongly discouraged for
    mathematical use because of their canonical equivalence to CJK
    punctuation.

[5] https://www.unicode.org/charts/PDF/U2300.pdf

Hence, switch to the MATHEMATICAL codepoints which seem to be the best
fit.

Fixes: https://github.com/xkbcommon/libxkbcommon/issues/47
Reported-by: @bytensky
Signed-off-by: Ran Benita <ran234@gmail.com>
2018-02-27 20:24:57 +02:00
Ran Benita b2529f2a88 build/autotools: remove redundant ACLOCAL_AMFLAGS
Will be deprecated in automake 2.0.

Replaced by AC_CONFIG_MACRO_DIR (already present) which is available
since autoconf 2.63.

Signed-off-by: Ran Benita <ran234@gmail.com>
2018-02-27 12:36:20 +02:00
Ran Benita 776cb52361 build/meson: fix x11 test/demo compilation with non-standard xcb
The x11 tests/demos did not depend on xcb and xcb-xkb directly, only
indirectly through link_with: libxkbcommon_x11_internal. So linking
worked, but the xcb and xcb-xkb cflags were *not* included when
compiling them. So when using xcb installed in a non-standard location,
what would happen is:

- Library will link with custom xcb and compile with custom xcb headers.
- Test will link with custom xcb and compile with system xcb headers (if
  exist, otherwise fail).

Fixes: https://github.com/xkbcommon/libxkbcommon/issues/57
Reported-by: @remexre
Signed-off-by: Ran Benita <ran234@gmail.com>
2018-02-25 11:59:04 +02:00
Ran Benita edb1c66239 build/meson: fix the -Wl,--version-script configure check
Hopefully this fixes compilation on darwin, which doesn't support
version scripts.

Signed-off-by: Ran Benita <ran234@gmail.com>
2018-02-14 15:10:03 +02:00
Ran Benita afea3dd0cd test/interactive-wayland: replace tabs with spaces
Match the style of all other files.

Signed-off-by: Ran Benita <ran234@gmail.com>
2018-01-27 20:42:44 +02:00
Ran Benita 740c66885f doc: improve the description of the consumed modifier modes
Hopefully it is more understandable now.

https://bugs.freedesktop.org/show_bug.cgi?id=104768

Reported-by: Gatis Paeglis <gatis.paeglis@qt.io>
Signed-off-by: Ran Benita <ran234@gmail.com>
2018-01-26 13:11:04 +02:00
Ran Benita 767fa86d42 Convert http:// -> https:// where possible
Signed-off-by: Ran Benita <ran234@gmail.com>
2017-12-21 14:18:07 +02:00
Ran Benita 4fccdee383 x11: check and document the correct range of device IDs
The actual value is 127, not 255.

https://bugs.freedesktop.org/show_bug.cgi?id=104321

Reported-by: Gatis Paeglis <gatis.paeglis@qt.io>
Signed-off-by: Ran Benita <ran234@gmail.com>
2017-12-18 16:41:21 +02:00
Ran Benita b82e3b764e Bump version to 0.8.0
Signed-off-by: Ran Benita <ran234@gmail.com>
2017-12-15 21:41:51 +02:00
Ran Benita 3db1b9d501 Update NEWS
Signed-off-by: Ran Benita <ran234@gmail.com>
2017-12-15 21:40:30 +02:00
Ran Benita 8ce81c0607 README,PACKAGING: use the new meson unified command format
Signed-off-by: Ran Benita <ran234@gmail.com>
2017-12-15 16:18:14 +02:00
Ran Benita 5c9042127f build: disable -Wdocumentation-deprecated-sync
We will never remove the deprecated functions and there is no real
reason to annoy users into stop using them.

If there *will* be a reason, *then* we will add the attribute.

Fixes: https://github.com/xkbcommon/libxkbcommon/issues/56
Signed-off-by: Ran Benita <ran234@gmail.com>
2017-12-14 17:56:18 +02:00
Ran Benita 10e1a1b1aa travis: ensure all tests are valgrind-clean
The tests will fail if they have any memory leaks or perform invalid
accesses.

Signed-off-by: Ran Benita <ran234@gmail.com>
2017-12-12 15:58:32 +02:00
Ran Benita 29998c258c test/x11: properly clean up also when skipping test
To make valgrind happy.

Signed-off-by: Ran Benita <ran234@gmail.com>
2017-12-12 15:58:32 +02:00
Ran Benita 47f45194e4 compose/parser: be more careful when checking if sequence overrides or duplicates another
Signed-off-by: Ran Benita <ran234@gmail.com>
2017-12-12 15:45:37 +02:00
Ran Benita 2963e29f0e xkbcomp/ast-build: fix memory leak when appending multi-keysyms
`syms` was not freed.

Signed-off-by: Ran Benita <ran234@gmail.com>
2017-12-12 14:44:01 +02:00
Ran Benita 26453b8473 keymap: fix NULL dereference when dumping the default fallback type
The default fallback type uses
    type->level_names = NULL
but the keymap-dump code was not checking this case.

Instead of adding more workarounds and possible bugs (e.g. previous
commit), let's just keep the number of level names separately. This has
the additional advantage retains extraneous level name if someone adds
them for some reason.

Signed-off-by: Ran Benita <ran234@gmail.com>
2017-12-12 14:33:24 +02:00
Ran Benita 9f85d6b78c xkbcomp/types: fix types being assigned the wrong number of levels in some circumstances
The buggy code assigned the number of levels based on the number of
level names in the definition, instead of the actual number of levels!
This would completely break type definitions which do not give names to
levels.

This was not noticed for so long because xkeyboard-config always gives
names to all levels.

This regressed in 61fed8dab9.

Reported-by: Gatis Paeglis <gatis.paeglis@qt.io>
Signed-off-by: Ran Benita <ran234@gmail.com>
2017-12-12 14:08:01 +02:00
Ran Benita 18d6aebec0 keysym: add xkb_keysym_to_{lower,upper} to public API
These can be useful in some odd cases.

There is already an implementation (+ tests) for internal use, so all
that's needed is to export them.

If xkbcommon were to provide a way to convert a Unicode codepoint to a
keysym, this could have been implemented externally as follows:

    uint32_t codepoint = xkb_keysym_to_utf32(keysym);
    uint32_t upper_codepoint = my_unicode_library_to_upper(codepoint);
    xkb_keysym_t upper_keysym = theoretical_xkb_keysym_from_utf32(upper_codepoint);

However keysym -> codepoint is not injective so such a function is not
possible strictly speaking.

Signed-off-by: Ran Benita <ran234@gmail.com>
2017-12-11 23:01:18 +02:00
Ran Benita 6456835f1c test/data: sync with xkeyboard-config 2.22
Some tweaks to the de(neo) keyseq tests were required. It seems to have
improved.

Signed-off-by: Ran Benita <ran234@gmail.com>
2017-12-03 13:07:21 +02:00
Ran Benita 8db924b87d Merge pull request #53 from whitslack/missing-ucs-codes
keysym-utf: Add missing codes for signifblank and permille keysyms
2017-10-03 13:28:32 +03:00
Matt Whitlock 0db1d3131a keysym-utf: Add missing codes for signifblank and permille keysyms 2017-09-28 21:31:28 -04:00
Ran Benita 5eeba0fe0d build/meson: require meson >= 0.41.0
With previous versions, the compilation fails with linker errors.

Fixes https://github.com/xkbcommon/libxkbcommon/issues/52
Reported-by: @rezso
Signed-off-by: Ran Benita <ran234@gmail.com>
2017-09-10 09:18:54 +03:00
Ran Benita 41f1018897 expr: paper over a maybe-uninitialized warning
Signed-off-by: Ran Benita <ran234@gmail.com>
2017-09-08 12:16:13 +03:00
Ran Benita 14686cd1a8 test/interactive-wayland: avoid unused function warning due to configuration
test/interactive-wayland.c:95:1: warning: ‘set_cloexec_or_close’ defined but not used [-Wunused-function]

Signed-off-by: Ran Benita <ran234@gmail.com>
2017-08-16 20:24:27 +03:00
Ran Benita 76348754e3 build: add missing configure function checks for test/interactive-wayland
Signed-off-by: Ran Benita <ran234@gmail.com>
2017-08-16 20:23:54 +03:00
Ran Benita f468f0b243 xkbcommon-compose.h: change recommended locale fallback code to treat empty string same as unset
The previous code would cause failures to find the Compose file if one
of the environment variables LC_ALL, LC_CTYPE or LANG are set to the
empty string.

The description of the fallback procedure in loclale(7) talks about
"non-null environment variable"; I interpreted this to mean the
environment variable is unset, but it actually means unset or empty (I
verified this by looking at what glibc and musl do).

A recent bug in systemd https://github.com/systemd/systemd/issues/6407
exposed this issue. It causes these these variables to be set to the
empty string in TTY sessions.

Reported by "doodoo" in https://bbs.archlinux.org/viewtopic.php?id=228658

Signed-off-by: Ran Benita <ran234@gmail.com>
2017-08-13 18:03:57 +03:00
Ran Benita ba9568bdb1 Bump version to 0.7.2
Signed-off-by: Ran Benita <ran234@gmail.com>
2017-08-04 16:28:36 +03:00
Ran Benita c99f6a5821 Update NEWS
Signed-off-by: Ran Benita <ran234@gmail.com>
2017-08-04 16:28:14 +03:00
Ran Benita 5c2da7795c build/autotools: fix doc installation
Signed-off-by: Ran Benita <ran234@gmail.com>
2017-08-04 15:43:13 +03:00
Ran Benita fbd86e44ad test/symbols-leak-test.bash: make it easier to read
Signed-off-by: Ran Benita <ran234@gmail.com>
2017-08-03 13:38:14 +03:00
Ran Benita 2a16c3c482 build/autotools: fix symbol versioning configure check
Regressed in 4309735. I thought `$top_srcdir` works in configure too,
apparently not!

See: https://github.com/xkbcommon/libxkbcommon/issues/50#issuecomment-319693694

Signed-off-by: Ran Benita <ran234@gmail.com>
2017-08-02 18:34:29 +03:00
Ran Benita c665b45011 build/autotools: make doxygen's input relative
Was meant to be a part of 41bea9a.

Signed-off-by: Ran Benita <ran234@gmail.com>
2017-08-02 18:26:19 +03:00