summaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)AuthorFilesLines
2024-01-17Fix dereference after NULL issueaccepted/tizen/unified/riscv/20240118.054547accepted/tizen/unified/20240117.163255accepted/tizen_unified_riscvJihoon Kim1-0/+3
Change-Id: I845ecb7e7fc6b6242e755a336f0e7e1429ae4bf9 Signed-off-by: Jihoon Kim <jihoon48.kim@samsung.com>
2024-01-03text.c: remove unreachable codeJihoon Kim1-3/+0
Change-Id: I56a7cf554d230cf7233e24c04b1f1ad1f318a194 Signed-off-by: Jihoon Kim <jihoon48.kim@samsung.com>
2023-12-22Fix build errorJihoon Kim2-3/+5
Change-Id: Ibaa726eb7ab77b4a9a51a7d3670bd27f8701fcf5 Signed-off-by: Jihoon Kim <jihoon48.kim@samsung.com>
2023-12-22text.c: use strncpy instead of strcpy for better securityduna.oh1-5/+5
Change-Id: Idf6357ae19655f5de30017ad575fdc6b3193cd96
2023-12-22Fix issue detected by static analysis toolJihoon Kim1-1/+1
Because sprintf assumes an arbitrarily long string, callers must be careful not to overflow the actual space of the destination. Change-Id: I4a3e641459d1da0f54db7eeb109447868906e394 Signed-off-by: Jihoon Kim <jihoon48.kim@samsung.com>
2023-12-22Fix dereference after NULL issueJihoon Kim1-7/+8
After having been compared to a NULL value at symbols.c 763, pointer 'act' is passed as 4th parameter in call to function 'HandleActionDef' at symbols.c 775, where it is dereferenced at action.c 788. Change-Id: Ib25edc48b26d523fa11a5e99d171750bd768b14d Signed-off-by: Jihoon Kim <jihoon48.kim@samsung.com>
2023-12-22Fix NULL after deref issue detected by static analysis toolJihoon Kim4-0/+12
Change-Id: Ib63eaf8969c1fb75e02683908b276d2fc1d13705 Signed-off-by: Jihoon Kim <jihoon48.kim@samsung.com>
2023-12-22table.c: Fix a coverity warning of uninitialized value 'dummy'Duna Oh1-1/+3
2023-12-22fix not to display error log about the absense of compose fileSung-Jin Park1-3/+8
All locale information except 'en_US.UTF-8' had been removed as a part of the uninstallation of unnecessary resources except the essential elements for basic key-mapping funtionality. As a result, if a locale is set to other than 'en_US.UTF-8', an error message is being displayed that says a compose file cannot be found. Actually, there is no problem with the behavior but it is often perceived by the developer(s) and tester(s) as an error. Thus, this fixes the search error for the compose file for another locale other than 'en_US.UTF-8' to not be displayed anymore. Change-Id: I37ead508bda79e71baf5d6743f1f6b059b6010a1 Signed-off-by: Sung-Jin Park <sj76.park@samsung.com>
2023-12-22xkbcomp: add null checkers after calloc()jeon1-1/+10
Change-Id: Ie5f050d20a678260f00778de20aad830c5b3208b
2023-12-22cast a function's return valueJengHyun Kang1-1/+1
Change-Id: I16fe4f7393941353ccc12eb9c365a6911d075a17
2023-12-22Add a new API to set key repeatJengHyun Kang1-0/+14
Change-Id: If1644c4c6575b4eb7cadb8c1e11147651013d8ef
2023-10-06Keysyms: Fix missing hpYdiaeresisPierre Le Marre1-2806/+2808
The handling of keysym name guards (e.g. `#ifndef XK_Ydiaeresis`) was incomplete and led to a missing keysym. Make `sripts/makeheader` more robust to C macros handling.
2023-09-28Keysyms: Update using latest xorgprotoPierre Le Marre1-3816/+3869
xorgproto commit: 1c8128d72df22843a2022576850bc5ab5e3a46ea.
2023-09-26Show invalid escape sequencesPierre Le Marre2-25/+29
It is easier to debug when the message actually displays the offending escape sequence.
2023-09-26Prevent overflow of octal escape sequencesPierre Le Marre1-1/+8
The octal parser accepts the range `\1..\777`. The result is cast to `char` which will silently overflow. This commit prevents overlow and will treat `\400..\777` as invalid escape sequences.
2023-09-26Disallow producing NULL character with escape sequencesPierre Le Marre4-5/+35
NULL usually terminates the strings; allowing to produce it via escape sequences may lead to undefined behaviour. - Make NULL escape sequences (e.g. `\0` and `\x0`) invalid. - Add corresponding test. - Introduce the new message: XKB_WARNING_INVALID_ESCAPE_SEQUENCE.
2023-09-26Compose: add iterator APIRan Benita5-3/+171
Allow users to iterate the entries in a compose table. This is useful for other projects which want programmable access to the sequences, without having to write their own parser. - New API: - `xkb_compose_table_entry_sequence`; - `xkb_compose_table_entry_keysym`; - `xkb_compose_table_entry_utf8`; - `xkb_compose_table_iterator_new`; - `xkb_compose_table_iterator_free`; - `xkb_compose_table_iterator_next`. - Add tests in `test/compose.c`. - Add benchmark for compose traversal. - `tools/compose.c`: - Print entries instead of just validating them. - Add `--file` option. - TODO: make this tool part of the xkbcli commands. Co-authored-by: Pierre Le Marre <dev@wismill.eu> Co-authored-by: Ran Benita <ran@unusedvar.com> Signed-off-by: Ran Benita <ran@unusedvar.com>
2023-09-24Messages: merge macros with and without message codePierre Le Marre22-230/+266
Previously we had two types of macros for logging: with and without message code. They were intended to be merged afterwards. The idea is to use a special code – `XKB_LOG_MESSAGE_NO_ID = 0` – that should *not* be displayed. But we would like to avoid checking this special code at run time. This is achieved using macro tricks; they are detailed in the code (see: `PREPEND_MESSAGE_ID`). Now it is also easier to spot the remaining undocumented log entries: just search `XKB_LOG_MESSAGE_NO_ID`.
2023-09-24Messages: add new messages to registryPierre Le Marre12-98/+307
This commit is another step to identify and document the maximum number of logging messages. Bulk changes: - Rename `conflicting-key-type` to `conflicting-key-type-merging-groups`. Giving more context in the name allow us to introduce `conflicting-key-type-definitions` later. - Add conflicting-key-type-definitions - Add conflicting-key-type-map-entry - Add undeclared-modifiers-in-key-type Also improve the log messages. - Add conflicting-key-type-preserve-entries - Use XKB_ERROR_UNSUPPORTED_MODIFIER_MASK - Add illegal-key-type-preserve-result - Add conflicting-key-type-level-names - Add duplicate-entry - Add unsupported-symbols-field - Add missing-symbols-group-name-index - Use XKB_ERROR_WRONG_FIELD_TYPE - Add conflicting-key-name - Use XKB_WARNING_UNDEFINED_KEYCODE - Add illegal-keycode-alias - Add unsupported-geometry-section - Add missing-default-section - Add XKB_LOG_MESSAGE_NO_ID - Rename log_vrb_with_code to log_vrb - Use ERROR_WRONG_FIELD_TYPE & ERROR_INVALID_SYNTAX - Add unknown-identifier - Add invalid-expression-type - Add invalid-operation + fixes - Add unknown-operator - Rename ERROR_UNKNOWN_IDENTIFIER to ERROR_INVALID_IDENTIFIER - Add undeclared-virtual-modifier - Add expected-array-entry - Add invalid-include-statement - Add included-file-not-found - Add allocation-error - Add invalid-included-file - Process symbols.c - Add invalid-value - Add invalid-real-modifier - Add unknown-field - Add wrong-scope - Add invalid-modmap-entry - Add wrong-statement-type - Add conflicting-key-symbols-entry - Add invalid-set-default-statement
2023-09-19Add a new warning for numeric keysymsPierre Le Marre3-0/+10
Usually it is better to use the corresponding human-friendly keysym names. If there is none, then the keysym is most probably not supported in the ecosystem. The only use case I see is similar to the PUA in Unicode (see: https://en.wikipedia.org/wiki/Private_Use_Areas). I am not aware of examples of this kind of use.
2023-09-19Structured log messages with a message registryPierre Le Marre13-85/+261
Currently there is little structure in the log messages, making difficult to use them for the following use cases: - A user looking for help about a log message: the user probably uses a search engine, thus the results will depend on the proper indexing of our documentation and the various forums. It relies only on the wording of the message, which may change with time. - A user wants to filter the logs resulting of the use of one of the components of xkbcommon. A typical example would be testing xkeyboard-config against libxkbcommon. It requires the use of a pattern (simple words detection or regex). The issue is that the pattern may become silently out-of-sync with xkbcommon. A common practice (e.g. in compilers) is to assign unique error codes to reference theses messages, along with an error index for documentation. Thus this commit implements the following features: - Create a message registry (message-registry.yaml) that defines the log messages produced by xkbcommon. This is a simple YAML file that provides, for each message: - A unique numeric code as a short identifier. It is used in the output message and thus can be easily be filtered to spot errors or searched in the internet. It must not change: if the semantics of message changes, it is better to introduce a new message for clarity. - A unique text identifier, meant for two uses: 1. Generate constants dealing with log information in our code base. 2. Generate human-friendly names for the documentation. - A type: currently warning or error. Used to prefix the constants (see hereinabove) and for basic classification in documentation. - A short description, used as concise and mandatory documentation. - An optionnal detailed description. - Optional examples, intended to help the user to fix issues themself. - Version of xkbcommon it was added. For old entries this often unknown, so they will default to 1.0.0. - Version of xkbcommon it was removed (optional) No entry should ever be deleted from this index, even if the message is not used anymore: it ensures we have unique identifiers along the history of xkbcommon, and that users can refer to the documentation even for older versions. - Add the script update-message-registry.py to generate the following files: - messages.h: message code enumeration for the messages currently used in the code base. Currently a private API. - message.registry.md: the error index documentation page. - Modify the logging functions to use structured messages. This is a work in progress.
2023-08-05parser: change deprecated `%pure-parser` to `%define api.pure` (#370)M Kelly1-1/+1
This is now supported by byacc since version 2.0 20230516
2023-07-14Fix parsing of numeric keysyms in ExprResolveKeySymPierre Le Marre1-3/+19
`ExprResolveKeySym` in `expr.c` does not parse non-digit numeric keysyms. Fixed by checking upper bound; also add warning messages.
2023-07-14Simplify parsing of numeric keysyms in parser.yPierre Le Marre1-5/+7
In `parser.y`, a numeric keysym is parsed by formatting it in its hexadecimal form then parsed as a keysym name. This is convoluted. Fixed by checking directly the upper bound.
2023-07-14Fix xkb_keysym_from_name for numeric keysymsPierre Le Marre1-0/+2
When parsing hexadecimal keysym using `xkb_keysym_from_name`, the result is limited by `parse_keysym_hex` to 0xffffffff, but the maximum keysym is XKB_MAX_KEYSYM, i.e. 0x1fffffff. Fixed by adding an upper bound.
2023-07-14Move STRINGIFY to utils.h and add STRINGIFY2Pierre Le Marre2-1/+3
2023-07-14Add XKB_KEYSYM_MIN and XKB_KEYSYM_MAXPierre Le Marre2-1/+9
Keysyms are 32-bit integers with the 3 most significant bits always set to zero. See: Appendix A “KEYSYM Encoding” of the X Window System Protocol at https://www.x.org/releases/current/doc/xproto/x11protocol.html#keysym_encoding. Add a new constants XKB_KEYSYM_MIN and XKB_KEYSYM_MAX to make the interval of valid keysyms more obvious in the code.
2023-05-15compose: drop the 65535 node limit (#343)alois313-10/+11
In commit 1638409b22aef33d487863876ab214b949db4984, the number of compose nodes was limited to 65535 to enable "future optimizations", which apparently means slightly reduced memory usage due to fitting in a uint16_t. At this time, it was mentioned that the author was not aware of "any compose files which come close". However, I'm one of the users that actually do require a larger number of nodes for their compose file. Thus, use a uint32_t again and raise the limit significantly.
2023-05-13Do not interpret nor emit invalid Unicode encoding formsPierre Le Marre2-5/+27
Surrogates are invalid in both UTF-32 and UTF-8. See https://www.unicode.org/versions/Unicode15.0.0/ch03.pdf#G28875 and https://www.unicode.org/versions/Unicode15.0.0/ch03.pdf#G31703
2023-05-13Add warning when RMLVO with no layout but variant setPierre Le Marre1-0/+10
There is no feedback that they are both replaced with default values. Fix it by adding a warning informing about missing layout and show the defaults for both.
2023-05-06utils: fix printf format warnings on mingwRan Benita1-1/+3
See: https://github.com/mesonbuild/wrapdb/pull/819 https://github.com/Exiv2/exiv2/blob/c86ae6acf597304db37246434ebc393d732c22c2/src/image_int.hpp#L15 https://sourceforge.net/p/mingw-w64/wiki2/gnu%20printf/ Signed-off-by: Ran Benita <ran@unusedvar.com>
2023-05-05scanner: allow for a zero terminated string as keymapPeter Hutterer1-0/+4
As the documentation for xkb_keymap_new_from_buffer() states, the "input string does not have to be zero-terminated". The actual implementation however failed with "unrecognized token/syntax error" when it encountered a null byte. Fix this by allowing a null byte at the last position of the buffer. Anything else is likely a client error anyway. Fixes #307
2023-05-04registry: remove a few asprintf/free() calls with snprintfPeter Hutterer1-13/+4
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2023-05-04registry: simplify strdup() error handlingPeter Hutterer1-12/+8
strdup() is the least likely call to fail here, let's move it to the bottom so we don't need to worry about the allocated string. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2023-05-01Add support for modmap None (#291)Wismill4-9/+30
Unlike current xkbcommon, X11’s xkbcomp allows to remove entries in the modifiers’ map using “modifier_map None { … }”. “None” is translated to the special value “XkbNoModifier” defined in “X11/extensions/XKB.h”. Then it relies on the fact that in "CopyModMapDef", the following code: 1U << entry->modifier ends up being zero when “entry->modifier” is “XkbNoModifier” (i.e. 0xFF). Indeed, it relies on the overflow behaviour of the left shift, which in practice resolves to use only the 5 low bits of the shift amount, i.e. 0x1F here. Then the result of “1U << 0xFF” is cast to “char”, i.e. 0. This is a good trick but too magical, so in libxkbcommon we will use an explicit test against our new constant XKB_MOD_NONE.
2023-04-12keysyms: add new keysyms XF86EmojiPicker, XF86DictateRan Benita1-862/+867
Ref: https://gitlab.freedesktop.org/xorg/proto/xorgproto/-/commit/914d8f5e0f469cd0416364dd008e9eea752bf703 Ref: https://gitlab.freedesktop.org/xorg/proto/xorgproto/-/commit/a839f0c7fc5596d10e786394d3b0953eb8a1731b Signed-off-by: Ran Benita <ran@unusedvar.com>
2023-04-11Possible fix for non-MSVC windows compilersRan Benita1-1/+1
`_MSC_VER` is specific to MSVC, but there can be other compilers targeting windows. Hopefully they do define `_WIN32`, so let's use that. Refs: https://github.com/xkbcommon/libxkbcommon/issues/305 Signed-off-by: Ran Benita <ran@unusedvar.com>
2023-03-31keysym: replace deprecated Serbian_DZE with Cyrillic_DZHEPeter Hutterer1-2/+2
Same numeric value for both and the Serbian one has been listed as deprecated for decades. See https://gitlab.freedesktop.org/xorg/proto/xorgproto/-/merge_requests/69#note_1843415 Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-12-16context: add XKB_CONTEXT_NO_SECURE_GETENV flag (#312)Ronan Pigott9-52/+81
This flag is useful for clients that may have relatively benign capabilities set, like CAP_SYS_NICE, that also want to use the xkb configuration from the environment and user configs in XDG_CONFIG_HOME. Fixes: https://github.com/xkbcommon/libxkbcommon/issues/308 Fixes: https://github.com/xkbcommon/libxkbcommon/issues/129 Signed-off-by: Ran Benita <ran@unusedvar.com>
2022-09-24utils: move some MSVC compat stuff to common placeRan Benita2-14/+13
Signed-off-by: Ran Benita <ran@unusedvar.com>
2022-05-15keysym-utf: remove bogus currency sign entriesRan Benita1-11/+0
These ended up being mapping in the 0x100xxxx Unicode range, which are handled automatically ; these special keysyms don't exist (except for EuroSign). #define XKB_KEY_EcuSign 0x10020a0 /* U+20A0 EURO-CURRENCY SIGN */ #define XKB_KEY_ColonSign 0x10020a1 /* U+20A1 COLON SIGN */ #define XKB_KEY_CruzeiroSign 0x10020a2 /* U+20A2 CRUZEIRO SIGN */ #define XKB_KEY_FFrancSign 0x10020a3 /* U+20A3 FRENCH FRANC SIGN */ #define XKB_KEY_LiraSign 0x10020a4 /* U+20A4 LIRA SIGN */ #define XKB_KEY_MillSign 0x10020a5 /* U+20A5 MILL SIGN */ #define XKB_KEY_NairaSign 0x10020a6 /* U+20A6 NAIRA SIGN */ #define XKB_KEY_PesetaSign 0x10020a7 /* U+20A7 PESETA SIGN */ #define XKB_KEY_RupeeSign 0x10020a8 /* U+20A8 RUPEE SIGN */ #define XKB_KEY_WonSign 0x10020a9 /* U+20A9 WON SIGN */ #define XKB_KEY_NewSheqelSign 0x10020aa /* U+20AA NEW SHEQEL SIGN */ #define XKB_KEY_DongSign 0x10020ab /* U+20AB DONG SIGN */ #define XKB_KEY_EuroSign 0x20ac /* U+20AC EURO SIGN */ Signed-off-by: Ran Benita <ran@unusedvar.com>
2022-05-15keysym-utf: remove bogus Korean Won sign entryRan Benita1-1/+0
This entry maps a non existing special keysym 0x20a9. The correct mapping for XKB_KEY_Korean_Won (0x0eff) already exists. Signed-off-by: Ran Benita <ran@unusedvar.com>
2022-05-15Remove bogus euro sign entry from keysymtabSam Lantinga1-1/+0
Not sure what it's doing here, but converting "€" to a keysym doesn't work with this entry. 0x13a4 doesn't appear in xkbcommon-keysyms.h. 0x20ac is the keysym documented in the header (and it's the last entry in the table). It's been in the table since it was introduced in e0524296d2e0 ("Add API for getting unicode representation of a keysym"). Co-authored-by: Simon Ser <contact@emersion.fr>
2022-05-15Do not clear sibling entries when override.Weng Xuetian1-1/+1
lokid and hikid actually stores the sibling to current node, which should not be cleared when override. This would break the sequence with a common prefix when override another. Fix #286 Signed-off-by: Weng Xuetian <wengxt@gmail.com>
2022-03-14scanner: prefix functions with `scanner_` to avoid symbol conflictsRan Benita4-151/+151
Particularly `eof()` in mingw-w64. Fixes: https://github.com/xkbcommon/libxkbcommon/pull/285 Reported-by: Marko Lindqvist Signed-off-by: Ran Benita <ran@unusedvar.com>
2022-01-24Variants should inherit iso639, iso3166 and brief from parent layout if ↵M Hickford1-3/+28
omitted (#266)
2022-01-24registry: skip over invalid ISO639 or ISO3166 entriesPeter Hutterer1-0/+10
If the XML file is somehow off, don't load entries that are against the spec.
2022-01-18registry: don't call xmlCleanupParser()Peter Hutterer1-1/+0
From the documentation: > It does not clean up parser state, it cleans up memory allocated by the library > itself. It is a cleanup function for the XML library. It tries to reclaim all > related global memory allocated for the library processing. [...] > One should call xmlCleanupParser() only when the process has finished using the library. http://xmlsoft.org/html/libxml-parser.html#xmlCleanupParser Since we're a library ourselves we cannot know if something else in the same proces uses the parser, so we must not call this. Reported-by: M Hickford
2021-09-09x11: try to fix crash in xkb_x11_keymap_new_from_device error handlingRan Benita1-12/+30
In 1b3a1c277a033083fee669e92c8cad862716ebd1 we changed the error handling in this code to not bail out immediately but only after everything has been processed, to simplify the code. But I suspect the code isn't prepared for this and that's what causing the crash reported in the issue. Bring back the short-circuit error handling which would hopefully fix such crashes. Fixes: https://github.com/xkbcommon/libxkbcommon/issues/252 Signed-off-by: Ran Benita <ran@unusedvar.com>