aboutsummaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)AuthorFilesLines
2023-08-27Release v0.19HEADv0.19masterKrzysztof Kozlowski2-1/+6
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
2023-08-18doc: Add uid to tag-apiVinicius Franchini1-0/+3
Add the Uid property to the tag-api documentation. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
2023-08-18tag: Remove unnecessary 'const' qualifierVinicius Franchini1-1/+1
Compilation process was failing due 'const' qualifier ignored, triggered by the ignored-qualifier flag. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
2023-08-18tag: Implement readout of tag UID via DBus interfaceFrieder Schrempf1-3/+54
This adds a 'Uid' property to the DBus interface for tags, which returns the UID of the tag as byte array. Signed-off-by: Frieder Schrempf <frieder.schrempf@kontron.de> Link: https://lore.kernel.org/r/20210311085020.429987-1-frieder.schrempf@kontron.de Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
2023-07-14ci: list all Debian stable versions for cross compilingKrzysztof Kozlowski1-0/+64
All currently supported Debian stable versions are already build on x86_64, but cross compiling is as well important. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
2023-07-14ci: add Debian Bullseye i386 and GCC sanitizersKrzysztof Kozlowski1-0/+20
Add i386 and GCC sanitizer builds on Debian Bullseye. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
2023-07-14ci/debian: use dpkg-architecture to detect gcc-cross package nameDmitry Baryshkov1-11/+1
Rather than specifying GCC packages manually, generate package name using dpkg-architecture. Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
2023-07-14ci/debian: don't install libc6-dev-ARCH-cross packagesDmitry Baryshkov1-5/+5
There is no need to manually install libc6-dev-ARCH-cross packages. Corresponding target arch packages will be pulled out via the dependency of library dev packages. Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
2023-07-04ci: run builds periodicallyKrzysztof Kozlowski1-1/+7
There is not much activity happening in neard, thus workflows triggered on changes might never run. In the same time distros actually change. Run at least once per week, to be sure it still builds even without development activity. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
2023-05-01ci: bump actions/checkout to v3 also for CodeQLKrzysztof Kozlowski1-1/+1
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
2023-05-01ci: bump CodeQL version to v2Krzysztof Kozlowski1-2/+2
v1 CodeQL got deprecated: This version of the CodeQL Action was deprecated on January 18th, 2023, and is no longer updated or supported. For better performance, improved security, and new features, upgrade to v2. For more information Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
2023-05-01ci: refresh distros - drop Debian Stretch, add Ubuntu and FedoraKrzysztof Kozlowski1-15/+3
Drop Debian Stretch: Err:6 http://deb.debian.org/debian stretch-updates Release 404 Not Found E: The repository 'http://deb.debian.org/debian stretch Release' does not have a Release file. E: The repository 'http://security.debian.org/debian-security stretch/updates Release' does not have a Release file. E: The repository 'http://deb.debian.org/debian stretch-updates Release' does not have a Release file. Add Ubuntu Lunar and Fedora 38 and 39. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
2023-05-01ci: allow manual run of workflowsKrzysztof Kozlowski2-4/+6
While touching the copyrights, update my email address. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
2023-01-20ci: bump actions/checkout to v3Krzysztof Kozlowski1-1/+1
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
2023-01-20ci: add Bookworm, Fedora 36+37, Ubuntu KineticKrzysztof Kozlowski1-0/+24
Add new systems for CI. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
2023-01-20ci: drop Ubuntu Hirsute and ImpishKrzysztof Kozlowski1-42/+0
Drop old, unsupported Ubuntu Hirsute and Impish from CI matrix. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
2022-06-01ci: build on newest Ubuntu Jammy Jellyfish (22.04)Krzysztof Kozlowski1-0/+21
Add building under CI on Ubuntu Jammy Jellyfish (22.04). Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
2022-02-17include: sync nfc_copy.h with Linux kernel v5.17-rc4Krzysztof Kozlowski1-3/+3
Use include/uapi/linux/nfc.h from Linux kernel v5.17-rc4. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2022-02-17ci: build on newer Fedora Linux (34 and 35)Krzysztof Kozlowski1-2/+2
Support for Fedora Linux 32 and 33 ended, so switch to new Fedora Linux 34 and 35. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2022-02-17ci: show kernel headers version and difference against embedded nfc.hKrzysztof Kozlowski1-0/+9
We embed the /usr/include/linux/nfc.h as nfc_copy.h, to compile cleanly on older kernels (e.g. older than v4.15 without NFC_CMD_DEACTIVATE_TARGET). See also commit fb7664e2995f ("include: Add a copy of the NFC kernel header"). We should sync our local nfc_copy.h with kernel sources from time to time, but it is easy to forget this. Add a separate Continuous Integration step to show kernel headers version and differences between kernel's nfc.h and our local copy, so we can notice kernel uses a different one. This is purely for maintenance. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2022-02-13build: install org.neard.se.conf dbus configuration fileJami Kettunen1-0/+4
Without this attempting to launch seeld as root resulted in: Connection ":1.0" is not allowed to own the service "org.neard.se" due to security policies in the configuration file
2021-11-22Release v0.18v0.18Krzysztof Kozlowski2-1/+8
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-11-11ci: add Debian Testing for i386 and cross compileKrzysztof Kozlowski1-0/+42
Build also Debian Testing on i386 and cross compile configurations. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-11-11ci: add Debian Buster and StretchKrzysztof Kozlowski1-1/+38
Add older releases of Debian: Buster and Stretch. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-11-11ci: add Ubuntu Impish (21.10)Krzysztof Kozlowski1-0/+21
Build on newest Ubuntu 21.10. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-11-11include: include endian.h to fix missing __BYTE_ORDER definition on Debian ↵Krzysztof Kozlowski1-0/+1
Stretch Code should pull explicitly headers for necessary symbols instead of relying on dependencies. Lack of endian.h caused build failures on Debian Stretch: In file included from tools/nfctool/ndef-decode.c:28:0: include/near/types.h:43:5: error: "__BYTE_ORDER" is not defined [-Werror=undef] #if __BYTE_ORDER == __LITTLE_ENDIAN Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-10-10adapter: use sockaddr_storage to solve uninitialized sa_data accessKrzysztof Kozlowski1-6/+8
On x86_64 valgrind complains when reading a tag: neard[15754]: src/tag.c:tag_initialize() neard[15754]: src/tag.c:set_tag_type() protocol 0x8 sens_res 0x0 sel_res 0x0 neard[15754]: src/tag.c:set_tag_type() tag type 0x3 neard[15754]: src/tag.c:__near_tag_add() connection 0x513aeb0 neard[15754]: src/adapter.c:near_adapter_connect() idx 0 ==15754== Syscall param socketcall.connect(serv_addr.sa_data) points to uninitialised byte(s) ==15754== at 0x4B45057: connect (connect.c:26) ==15754== by 0x1306D8: near_adapter_connect (adapter.c:1068) ==15754== by 0x130BB3: adapter_add_tag (adapter.c:754) ==15754== by 0x130BB3: __near_adapter_add_target (adapter.c:841) ==15754== by 0x13462D: get_targets_handler (netlink.c:574) ==15754== by 0x4A11DF0: nl_recvmsgs_report (in /usr/lib/x86_64-linux-gnu/libnl-3.so.200.26.0) ==15754== by 0x4A122CC: nl_recvmsgs (in /usr/lib/x86_64-linux-gnu/libnl-3.so.200.26.0) ==15754== by 0x134262: __nl_send_msg (netlink.c:151) ==15754== by 0x13494E: nfc_netlink_event_targets_found.isra.0 (netlink.c:627) ==15754== by 0x134DB4: nfc_netlink_event (netlink.c:780) ==15754== by 0x4A11DF0: nl_recvmsgs_report (in /usr/lib/x86_64-linux-gnu/libnl-3.so.200.26.0) ==15754== by 0x4A122CC: nl_recvmsgs (in /usr/lib/x86_64-linux-gnu/libnl-3.so.200.26.0) ==15754== by 0x13483B: __nfc_netlink_event (netlink.c:837) ==15754== by 0x13483B: __nfc_netlink_event (netlink.c:821) ==15754== Address 0x1ffefffa82 is on thread 1's stack ==15754== in frame #1, created by near_adapter_connect (adapter.c:1038) ==15754== neard[15754]: src/tag.c:__near_tag_read() type 0x3 neard[15754]: src/adapter.c:__near_adapter_stop_check_presence() neard[15754]: src/tag.c:__near_tag_read() driver type 0x1 neard[15754]: src/tag.c:__near_tag_read() driver type 0x2 neard[15754]: src/tag.c:__near_tag_read() driver type 0x3 Due to alignment the actual sizeof(sockaddr_nfc) is 16 bytes, but only first 14 bytes are initialized. Valgrind complains about remaining two bytes. Solve it by using more generic storage - sockaddr_storage. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-09-23Check if AX_CHECK_COMPILE_FLAG is available or print errorMikel Olasagasti Uranga1-1/+3
Resolves warning: AX_CHECK_COMPILE_FLAG is m4_require'd but not m4_defun'd reported by autoreconf: autoreconf -ivf --warnings=all autoreconf: Entering directory `.' autoreconf: configure.ac: not using Gettext autoreconf: running: aclocal --force --warnings=all -I m4 aclocal: warning: couldn't open directory 'm4': No such file or directory configure.ac:43: warning: AX_CHECK_COMPILE_FLAG is m4_require'd but not m4_defun'd accflags.m4:1: NEARD_COMPILER_FLAGS is expanded from... configure.ac:43: the top level configure.ac:43: warning: AX_CHECK_COMPILE_FLAG is m4_require'd but not m4_defun'd accflags.m4:1: NEARD_COMPILER_FLAGS is expanded from... configure.ac:43: the top level autoreconf: configure.ac: tracing configure.ac:43: warning: AX_CHECK_COMPILE_FLAG is m4_require'd but not m4_defun'd
2021-09-22ci: group package installation on AlpineKrzysztof Kozlowski1-5/+5
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-09-22HACKING: rephrase message about dependenciesKrzysztof Kozlowski1-1/+1
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-09-22ci: install pkg-configKrzysztof Kozlowski3-0/+3
Some newer distros (e.g. Fedora 35) might not pull pkg-config and print confusing errors like: configure.ac:61: error: possibly undefined macro: AC_MSG_ERROR If this token and others are legitimate, please use m4_pattern_allow. See the Autoconf documentation. configure.ac:179: error: possibly undefined macro: AC_DEFINE Configure explicitly uses pkg-config so install it always. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-09-22ci: add ArchLinux containerKrzysztof Kozlowski2-0/+31
Build in ArchLinux latest container. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-09-22ci: add more Fedora containersKrzysztof Kozlowski2-5/+12
Build in Fedora rawhide and in stable release containers. Rawhide fails to install packages in two rounds (with two dnf/yum commands), so combine these. Rawhide also needs explicit pkg-config as it is not pulled in by other packages. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-09-22ci: switch to dnf on FedoraKrzysztof Kozlowski1-2/+2
dnf is the new package manager on Fedora. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-09-22build: replace deprecated AC_HELP_STRINGKrzysztof Kozlowski1-3/+3
AC_HELP_STRING is deprecated in favor of AS_HELP_STRING at least since autoconf v2.60. In autoconf v2.71 (used on current ArchLinux and Fedora Rawhide) this causes error: configure.ac:112: warning: The macro `AC_HELP_STRING' is obsolete. configure.ac:112: You should run autoupdate. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-09-22build: adjust configure.ac syntax to match autoupdateKrzysztof Kozlowski1-2/+2
Effect of autoupdate, without changing the version. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-09-22Release v0.17v0.17Krzysztof Kozlowski2-1/+9
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-08-07ndef: Only register interface for known recordsRicardo Ribalda Delgado1-1/+15
If we register the interface for unknown/error records neard daemon will crash with no useful output message. ... neard[2404]: src/ndef.c:aar_exists() No AAR neard[2404]: src/ndef.c:mime_payload_exists() No MIME payload neard[2404]: D-Bus disconnect neard[2404]: D-Bus disconnect (BT) ... Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com> [mag: Removed dead url] Signed-off-by: Mark Greer <mgreer@animalcreek.com>
2021-08-04README: describe contributionsKrzysztof Kozlowski1-0/+18
Mention the linux-nfc mailing list for contributions and current repositories - GitHub and kernel.org. Document explicitly that contributions can come also via GitHub pull request. For many developers without experience in development of Linux kernel, the GitHub PRs are easier than the patch-email workflow. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-08-04build: fix missing pkglibdir substitute in neard.pcKrzysztof Kozlowski1-0/+4
The pkglibdir is used by neard.pc.in (so by autoconf) however the automake defines it, not autoconf. Add early definition of pkglibdir so substitute in neard.pc.in will work correctly. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-08-02ci: use matrix instead of duplicating each build configurationKrzysztof Kozlowski2-190/+114
Use matrix to list all typical configurations which allows easily to build different distros with clang and maintainer mode. This extends the number of jobs considerably but makes the entire CI YAML file smaller and easier to understand. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-08-02ci: print configure logs on failuresKrzysztof Kozlowski1-0/+6
Helps debugging of container-specific configure failures. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-08-02ci: add CodeQL static analysisKrzysztof Kozlowski1-0/+45
Add Github CodeQL static analysis workflow. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-08-02ci: add build with sanitizers (asan, lsan and ubsan)Krzysztof Kozlowski3-2/+61
Check the results if sanitizers were correctly linked. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-08-02ci: run unit testsKrzysztof Kozlowski1-0/+11
Although unit tests are executed as part of distcheck, but add it as a dedicated step to make it explicit with getting the logs afterwards. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-08-02ci: add more build configurations (Fedora, Alpine, Debian, cross-compile, i386)Krzysztof Kozlowski8-7/+309
The installation scripts were based on LTP project. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-08-02ci: be verbose when buildingKrzysztof Kozlowski1-1/+3
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-08-02ci: add building without maintainer optionsKrzysztof Kozlowski1-1/+35
Check also silent builds. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-08-02ci: add clang buildsKrzysztof Kozlowski2-2/+18
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-08-02bootstrap: parse CROSS_COMPILE and set proper configure optionKrzysztof Kozlowski1-0/+6
Makes cross compiling in CI easier. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-08-02ci: add GitHub actions for buildingKrzysztof Kozlowski3-0/+112
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-07-19AUTHORS: Mention Krzysztof Kozlowski's contributionsKrzysztof Kozlowski1-0/+1
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-07-19build: add support for GCC sanitizers (asan, lsan and ubsan)Krzysztof Kozlowski3-1/+85
Add support for GCC sanitizers: address (asan), leak (lsan) and undefined behavior (ubsan). These can be toggled in ./configure with --enable-asan, --enable-lsan and --enable-ubsan. The autoconf code for this derived from ell (mostly authored by Mat Martineau <mathew.j.martineau@linux.intel.com>): https://git.kernel.org/pub/scm/libs/ell/ell.git Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-07-19build: fix missing usage of PIE check resultKrzysztof Kozlowski1-1/+1
The test result whether compiler accepts -fPIE in acinclude.m4 is stored as neard_cv_prog_cc_pie variable. Using wrong name of that variable in a test for accepting '--enable-pie' configure argument caused PIE to be never enabled (unless by default by compiler). Fixes: 10c7e4a3cec3 ("build: Namespace local macros with NEARD_ instead of AC_ or nothing") Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-07-19build: enable -Wunsafe-loop-optimizations and -Wstrict-overflow=2 warningsKrzysztof Kozlowski1-2/+9
Enable basic overflow in optimization checks (portability related) and missed loop optimizations. The latter (-Wunsafe-loop-optimizations) does not work well with GCC v7.5 so simply skip it there. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-07-19build: enable -Wformat=2 warningsKrzysztof Kozlowski1-0/+1
The -Wformat=2 compiler warning can detect potentials errors when using printf-like functions. It is supported by GCC and clang. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-07-19build: enable -Wshadow and -Wformat-signedness compiler warningsKrzysztof Kozlowski1-4/+3
Enable code quality warnings - shadowing variables and using wrong signed data in formats (leading to conversions). Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-07-19build: add more compiler warningsKrzysztof Kozlowski4-19/+49
Use the AX_CHECK_COMPILE_FLAG() macro from autoconf-archive to check for support for more compiler warning flags (not enabled via -Wall and -Wextra) and enable these which pass. These flags are warning for: 1. Code bugs like dereferencing NULL or truncating string operations functions. 2. Minor code quality or portability issues like using undefined defines, wrong casts of functions, missing global function declarations, skipping variable initializations, duplicated if conditions or branches, usage of variable-length arrays. 3. Portability issues like implicit promoting float to double, allocating zero bytes or depending of size of void *. Keep more warnings for later, because the code does not build with them. The AX_CHECK_COMPILE_FLAG() macro tries to compile C code with given flag, so move the code from acinclude.m4 (executed early, before AC_LANG and others) to separate accflags.m4. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-07-19build: fix setting CFLAGS on dash shell (Alpine Linux)Krzysztof Kozlowski1-8/+9
Syntax like "CFLAGS+=" does not work on simple shells, e.g. dash from BusyBox. This seems to fail to properly configure CFLAGS on Alpine Linux: checking for pkg-config... /usr/bin/pkg-config checking pkg-config is at least version 0.9.0... yes ./configure: line 3441: CFLAGS+= -Werror -Wextra: not found ./configure: line 3442: CFLAGS+= -Wno-unused-parameter: not found ./configure: line 3443: CFLAGS+= -Wno-missing-field-initializers: not found ./configure: line 3444: CFLAGS+= -Wdeclaration-after-statement: not found ./configure: line 3445: CFLAGS+= -Wmissing-declarations: not found ./configure: line 3446: CFLAGS+= -Wredundant-decls: not found ./configure: line 3447: CFLAGS+= -Wcast-align: not found ./configure: line 3448: CFLAGS+= -DG_DISABLE_DEPRECATED: not found checking for gcc... gcc Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-07-19HACKING: refine required packagesKrzysztof Kozlowski1-11/+12
Debian since Jessie (8.0 from 2015) seems to have automake v1.14, so mentioning some specific configuration for it is not needed. In the same time other required libraries and tools are not mentioned, so let's refresh the requirements list. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-07-19unit: add few asserts in test-snep-readKrzysztof Kozlowski1-1/+10
For consistency, check for returned values of test_snep_build_req_frame()-like functions and __near_snep_core_init(). No functional change expected as all these are already tests. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-07-19unit: remove duplicated definitions in test-ndef-parseKrzysztof Kozlowski1-108/+1
The unit/test-ndef-parse.c duplicated several definitions which is error-prone. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-07-19unit: remove duplicated invalid definitions in test-snep-readKrzysztof Kozlowski5-217/+145
The unit tests duplicated several definitions in unit/test-utils.h which after some time become outdated and not matching the original ones. This lead to bogus data printed in logs, for example length of near_ndef_record: [SNEP unit] dummy_req_put STORED REC data=0x55ceb3fc8050 length=94346271294192 Move all of them into new src/ndef-private.h header. Start using SPDX identifier instead of full GPL license boilerplate. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-07-19unit: do not search for headers locally where they do not existKrzysztof Kozlowski2-4/+4
near/ndef.h and src/near.h are coming from include path, so no point to look for them in current folder. Also reverse the order to match unit/test-snep-read.c Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-07-19unit: do not pass NULL to memcpy()Krzysztof Kozlowski1-2/+4
memcpy() should not receive NULL as source pointer and such is passed from test_snep_read_get_req_frags_client_resp() and test_snep_read_verify_resp(). ASAN reports: unit/test-snep-read.c:325:2: runtime error: null pointer passed as argument 2, which is declared to never be null unit/test-snep-read.c:266:2: runtime error: null pointer passed as argument 2, which is declared to never be null Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-07-19unit: fix records GList memory leak in test-snep-readKrzysztof Kozlowski1-0/+1
The test_snep_dummy_req_put() stores one record in global stored_recd pointer, so the GList itself should be freed. This fixes Valgrind warning: 24 bytes in 1 blocks are definitely lost in loss record 21 of 30 at 0x483C7F3: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so) by 0x48CA698: g_malloc (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.6600.1) by 0x48E2CF1: g_slice_alloc (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.6600.1) by 0x48BFF07: g_list_append (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.6600.1) by 0x11E68A: near_ndef_parse_msg (ndef.c:2964) by 0x122A23: test_snep_dummy_req_put (test-snep-read.c:131) by 0x122005: snep_core_process_request (snep.c:397) by 0x122005: near_snep_core_read (snep.c:617) by 0x123042: test_snep_read_req_common.constprop.0 (test-snep-read.c:352) by 0x1234E0: test_snep_read_put_req_ok (test-snep-read.c:500) by 0x1234E0: test_snep_read_get_req_ok (test-snep-read.c:644) by 0x48ECDCD: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.6600.1) by 0x48ECBCA: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.6600.1) by 0x48ED2B9: g_test_run_suite (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.6600.1) Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-07-19unit: fix record memory leak in test-snep-readKrzysztof Kozlowski3-11/+1
Instead of open-coding __near_ndef_record_free() with mistakes, use it directly to fix memory leaks like: 2 bytes in 1 blocks are definitely lost in loss record 2 of 36 at 0x483C7F3: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so) by 0x48CA698: g_malloc (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.6600.1) by 0x48E4B3D: g_strndup (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.6600.1) by 0x11CB66: parse_record_header (ndef.c:1122) by 0x11CB66: parse_record_header (ndef.c:1029) by 0x11E549: near_ndef_parse_msg (ndef.c:2846) by 0x122A23: test_snep_dummy_req_put (test-snep-read.c:131) by 0x122005: snep_core_process_request (snep.c:397) by 0x122005: near_snep_core_read (snep.c:617) by 0x123042: test_snep_read_req_common.constprop.0 (test-snep-read.c:352) by 0x1234E0: test_snep_read_put_req_ok (test-snep-read.c:500) by 0x1234E0: test_snep_read_get_req_ok (test-snep-read.c:644) by 0x48ECDCD: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.6600.1) by 0x48ECBCA: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.6600.1) by 0x48ED2B9: g_test_run_suite (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.6600.1) 15 bytes in 1 blocks are definitely lost in loss record 13 of 36 at 0x483ED99: calloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so) by 0x11E65F: near_ndef_parse_msg (ndef.c:2958) by 0x122A23: test_snep_dummy_req_put (test-snep-read.c:131) by 0x122005: snep_core_process_request (snep.c:397) by 0x122005: near_snep_core_read (snep.c:617) by 0x123042: test_snep_read_req_common.constprop.0 (test-snep-read.c:352) by 0x1234E0: test_snep_read_put_req_ok (test-snep-read.c:500) by 0x1234E0: test_snep_read_get_req_ok (test-snep-read.c:644) by 0x48ECDCD: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.6600.1) by 0x48ECBCA: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.6600.1) by 0x48ED2B9: g_test_run_suite (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.6600.1) by 0x48ED2D4: g_test_run (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.6600.1) by 0x10F784: main (test-snep-read.c:967) Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-07-19unit: fix memory leaks in test-snep-read error pathsKrzysztof Kozlowski1-2/+6
Cleanup and free memory in error paths in test-snep-read.c. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-07-19unit: fix memory leaks in test-ndef-buildKrzysztof Kozlowski1-0/+6
test-ndef-build.c was not freeing the ndef records it got leading to memory leaks. Report by valgrind: (24 direct, 15 indirect) bytes in 1 blocks are definitely lost in loss record 24 of 38 at 0x483ED99: calloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so) by 0x11C176: ndef_message_alloc_complete.constprop.0 (ndef.c:1654) by 0x11FEC5: ndef_message_alloc (ndef.c:1760) by 0x11FEC5: near_ndef_prepare_text_record (ndef.c:3142) by 0x121676: test_ndef_text_build (test-ndef-build.c:63) by 0x48ECDCD: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.6600.1) by 0x48ECBCA: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.6600.1) by 0x48ED2B9: g_test_run_suite (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.6600.1) by 0x48ED2D4: g_test_run (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.6600.1) by 0x10F5A1: main (test-ndef-build.c:113) Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-07-19unit: do not open-code freeing ndef messageKrzysztof Kozlowski1-6/+3
Use near_ndef_msg_free() instead of open-coding it. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com> --- Changes since v1: 1. Change also test_snep_cleanup()
2021-07-19unit: fix memory leaks in test-ndef-parseKrzysztof Kozlowski1-34/+5
test-ndef-parse.c was not freeing fully the ndef records it got. Replace the open-coded freeing with usage of near_ndef_records_free() to solve libasan errors like: Direct leak of 8 byte(s) in 1 object(s) allocated from: #0 0x7f678a64b518 in calloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0xe9518) #1 0x557597045e89 in parse_sp_payload src/ndef.c:1468 #2 0x557597045e89 in near_ndef_parse_msg src/ndef.c:2921 and valgring errors like: 2 bytes in 1 blocks are definitely lost in loss record 2 of 52 at 0x483C7F3: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so) by 0x48CA698: g_malloc (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.6600.1) by 0x48E4B3D: g_strndup (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.6600.1) by 0x11C9F6: parse_record_header (ndef.c:1131) by 0x11C9F6: parse_record_header (ndef.c:1038) by 0x11E3D9: near_ndef_parse_msg (ndef.c:2855) by 0x121E6B: test_ndef_uri (test-ndef-parse.c:213) by 0x48ECDCD: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.6600.1) by 0x48ECBCA: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.6600.1) by 0x48ED2B9: g_test_run_suite (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.6600.1) by 0x48ED2D4: g_test_run (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.6600.1) by 0x10F61A: main (test-ndef-parse.c:467) Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-07-19unit: use proper format for integers (-Wformat)Krzysztof Kozlowski2-7/+7
Properly print signed and unsigned integers. This fixes warnings like: unit/test-ndef-parse.c: In function ‘test_ndef_single_sp’: unit/test-ndef-parse.c:318:33: error: field precision specifier ‘.*’ expects argument of type ‘int’, but argument 2 has type ‘uint32_t’ {aka ‘unsigned int’} [-Werror=format=] 318 | g_print("NDEF SP URI field: %.*s\n", uri->field_length, | ~~^~ ~~~~~~~~~~~~~~~~~ | | | | int uint32_t {aka unsigned int} unit/test-snep-read.c: In function ‘test_snep_dummy_req_put’: unit/test-snep-read.c:42:12: error: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘uint32_t’ {aka ‘unsigned int’} [-Werror=format=] 42 | g_printf("[SNEP unit] " fmt, ##__VA_ARGS__); \ | ^~~~~~~~~~~~~~ ...... 118 | frag_cnt, fragment->nfc_data_length, | ~~~~~~~~~~~~~~~~~~~~~~~~~ | | | uint32_t {aka unsigned int} unit/test-snep-read.c: In function ‘test_snep_read_verify_resp’: unit/test-snep-read.c:42:12: error: format ‘%X’ expects argument of type ‘unsigned int’, but argument 3 has type ‘int’ [-Werror=format=] 42 | g_printf("[SNEP unit] " fmt, ##__VA_ARGS__); \ | ^~~~~~~~~~~~~~ ...... 454 | resp->response, exp_resp_code); | ~~~~~~~~~~~~~ | | | int Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-07-19unit: do not shadow global 'uri' variable (-Wshadow)Krzysztof Kozlowski1-2/+2
Fix -Wshadow warnings like: unit/test-ndef-parse.c: In function ‘test_ndef_single_sp’: unit/test-ndef-parse.c:291:32: error: declaration of ‘uri’ shadows a global declaration [-Werror=shadow] 291 | struct near_ndef_uri_payload *uri; | ^~~ unit/test-ndef-parse.c:145:16: note: shadowed declaration is here 145 | static uint8_t uri[] = {0xd1, 0x1, 0xa, 0x55, 0x1, 0x69, 0x6e, 0x74, | ^~~ Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-07-19unit: do not shadow global 'text' variable (-Wshadow)Krzysztof Kozlowski1-4/+4
Fix -Wshadow warning: unit/test-ndef-parse.c: In function ‘test_ndef_title_sp’: unit/test-ndef-parse.c:194:33: error: declaration of ‘text’ shadows a global declaration [-Werror=shadow] 194 | struct near_ndef_text_payload *text; | ^~~~ unit/test-ndef-parse.c:42:16: note: shadowed declaration is here 42 | static uint8_t text[] = {0xd1, 0x1, 0x13, 0x54, 0x5, 0x65, 0x6e, 0x2d, | ^~~~ Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-07-19unit: use proper pointer to uint8_t in test_snep_read_recv_fragments()Krzysztof Kozlowski1-1/+1
Raw data bytes should be passed as pointer to uint8_t and the calling function already uses that type. This fixes warning: unit/test-snep-read.c: In function ‘test_snep_read_recv_fragments’: unit/test-snep-read.c:408:21: error: pointer of type ‘void *’ used in arithmetic [-Werror=pointer-arith] 408 | memcpy(data_recvd + offset, resp, nbytes); | ^ Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-07-19unit: use g_assert_cmpmem()Krzysztof Kozlowski3-8/+9
Comparisons of simple values should use test macros instead of checking standard library call return value. This prints more information on failure - the actual values used for comparisons. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-07-19unit: use g_assert_null()Krzysztof Kozlowski2-5/+5
It's more readable. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-07-19unit: fix recv() and send() return typesKrzysztof Kozlowski1-6/+10
The recv() and send() return negative number on errors, the return value should be stored in integer or ssize_t. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-07-19unit: use g_assert_cmpint() and g_assert_cmpuint()Krzysztof Kozlowski3-55/+56
Comparisons of simple values should use test macros instead of checking standard library call return value. This prints more information on failure - the actual values used for comparisons. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-07-19unit: use g_assert_cmpstr()Krzysztof Kozlowski1-8/+8
Comparisons of simple values should use test macros instead of checking standard library call return value. This prints more information: g_assert(): ERROR:unit/test-ndef-parse.c:256:test_ndef_text_encoding: assertion failed: (strcmp(record->text->language_code, "en-US1") == 0) g_assert_cmpstr(): ERROR:unit/test-ndef-parse.c:256:test_ndef_text_encoding: assertion failed (record->text->language_code == "en-US1"): ("en-US" == "en-US1") Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-07-19snep: fix fragmented response memory leaksKrzysztof Kozlowski1-0/+4
Sending long response might cause frame fragmentation and near_snep_core_response_with_info() does not free such 'struct p2p_snep_put_req_data'. It looks like freeing the fragmented response is task for snep_core_process_request as it already frees the fragments. Add also freeing the response itself to fix Valgrind (and ASAN) reported memory leaks: $ valgrind --leak-check=full unit/test-snep-read 80 bytes in 2 blocks are definitely lost in loss record 55 of 60 at 0x483ED99: calloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so) by 0x122496: near_snep_core_response_with_info (snep.c:762) by 0x122E21: test_snep_dummy_req_get (test-snep-read.c:179) by 0x121FF3: snep_core_process_request (snep.c:411) by 0x121FF3: near_snep_core_read (snep.c:616) by 0x122CC4: test_snep_read_req_common (test-snep-read.c:355) by 0x124792: test_snep_read_get_req_frags_client_resp (test-snep-read.c:760) by 0x48ECDCD: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.6600.1) by 0x48ECBCA: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.6600.1) by 0x48ED2B9: g_test_run_suite (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.6600.1) by 0x48ED2D4: g_test_run (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.6600.1) by 0x10F982: main (test-snep-read.c:976) Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-07-19snep: fix double free of GSListKrzysztof Kozlowski1-2/+0
g_slist_free_full() already frees entire GSList so calling it with g_slist_free causes a double free and memory corruption. This can be seen with Valgrind: Invalid read of size 8 at 0x48E3980: g_slice_free_chain_with_offset (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.6600.1) by 0x122075: snep_core_process_request (snep.c:481) by 0x122075: near_snep_core_read (snep.c:620) by 0x122CE4: test_snep_read_req_common (test-snep-read.c:348) by 0x12457A: test_snep_read_get_req_frags_client_resp (test-snep-read.c:775) by 0x48ECDCD: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.6600.1) by 0x48ECBCA: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.6600.1) by 0x48ED2B9: g_test_run_suite (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.6600.1) by 0x48ED2D4: g_test_run (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.6600.1) by 0x10F982: main (test-snep-read.c:960) Address 0x501e198 is 8 bytes inside a block of size 16 free'd at 0x483DA3F: free (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so) by 0x48E3971: g_slice_free_chain_with_offset (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.6600.1) by 0x122068: snep_core_process_request (snep.c:479) by 0x122068: near_snep_core_read (snep.c:620) by 0x122CE4: test_snep_read_req_common (test-snep-read.c:348) by 0x12457A: test_snep_read_get_req_frags_client_resp (test-snep-read.c:775) by 0x48ECDCD: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.6600.1) by 0x48ECBCA: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.6600.1) by 0x48ED2B9: g_test_run_suite (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.6600.1) by 0x48ED2D4: g_test_run (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.6600.1) by 0x10F982: main (test-snep-read.c:960) Block was alloc'd at at 0x483C7F3: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so) by 0x48CA698: g_malloc (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.6600.1) by 0x48E2CF1: g_slice_alloc (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.6600.1) by 0x48E4407: g_slist_append (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.6600.1) by 0x121AC7: snep_core_push_prepare_fragments (snep.c:377) by 0x121AC7: near_snep_core_response (snep.c:695) by 0x1224DB: near_snep_core_response_with_info (snep.c:779) by 0x122E41: test_snep_dummy_req_get (test-snep-read.c:172) by 0x121FF3: snep_core_process_request (snep.c:413) by 0x121FF3: near_snep_core_read (snep.c:620) by 0x122CE4: test_snep_read_req_common (test-snep-read.c:348) by 0x124449: test_snep_read_get_req_frags_client_resp (test-snep-read.c:746) by 0x48ECDCD: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.6600.1) by 0x48ECBCA: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.6600.1) Invalid free() / delete / delete[] / realloc() at 0x483DA3F: free (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so) by 0x48E3971: g_slice_free_chain_with_offset (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.6600.1) by 0x122075: snep_core_process_request (snep.c:481) by 0x122075: near_snep_core_read (snep.c:620) by 0x122CE4: test_snep_read_req_common (test-snep-read.c:348) by 0x12457A: test_snep_read_get_req_frags_client_resp (test-snep-read.c:775) by 0x48ECDCD: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.6600.1) by 0x48ECBCA: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.6600.1) by 0x48ED2B9: g_test_run_suite (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.6600.1) by 0x48ED2D4: g_test_run (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.6600.1) by 0x10F982: main (test-snep-read.c:960) Address 0x501e190 is 0 bytes inside a block of size 16 free'd at 0x483DA3F: free (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so) by 0x48E3971: g_slice_free_chain_with_offset (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.6600.1) by 0x122068: snep_core_process_request (snep.c:479) by 0x122068: near_snep_core_read (snep.c:620) by 0x122CE4: test_snep_read_req_common (test-snep-read.c:348) by 0x12457A: test_snep_read_get_req_frags_client_resp (test-snep-read.c:775) by 0x48ECDCD: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.6600.1) by 0x48ECBCA: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.6600.1) by 0x48ED2B9: g_test_run_suite (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.6600.1) by 0x48ED2D4: g_test_run (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.6600.1) by 0x10F982: main (test-snep-read.c:960) Block was alloc'd at at 0x483C7F3: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so) by 0x48CA698: g_malloc (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.6600.1) by 0x48E2CF1: g_slice_alloc (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.6600.1) by 0x48E4407: g_slist_append (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.6600.1) by 0x121AC7: snep_core_push_prepare_fragments (snep.c:377) by 0x121AC7: near_snep_core_response (snep.c:695) by 0x1224DB: near_snep_core_response_with_info (snep.c:779) by 0x122E41: test_snep_dummy_req_get (test-snep-read.c:172) by 0x121FF3: snep_core_process_request (snep.c:413) by 0x121FF3: near_snep_core_read (snep.c:620) by 0x122CE4: test_snep_read_req_common (test-snep-read.c:348) by 0x124449: test_snep_read_get_req_frags_client_resp (test-snep-read.c:746) by 0x48ECDCD: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.6600.1) by 0x48ECBCA: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.6600.1) Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-07-19snep: remove useless NULL-ify of local pointer variableKrzysztof Kozlowski1-1/+0
Assigning NULL to a local variable (a pointer) at the end of function does not have any effect as this NULL is not passed outside. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-07-19snep: do not open-code freeing ndef messageKrzysztof Kozlowski1-5/+2
Use near_ndef_msg_free() instead of open-coding it. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-07-19tag: do not open-code freeing ndef messageKrzysztof Kozlowski1-4/+2
Use near_ndef_msg_free() instead of open-coding it. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-07-19tag: use proper format for integers (-Wformat)Krzysztof Kozlowski1-4/+4
Properly print signed and unsigned integers. This fixes warnings like: src/tag.c: In function ‘near_tag_get_tag’: src/tag.c:99:33: error: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘uint32_t’ {aka ‘unsigned int’} [-Werror=format=] 99 | path = g_strdup_printf("%s/nfc%d/tag%d", NFC_PATH, | ~^ | | | int | %d 100 | adapter_idx, target_idx); | ~~~~~~~~~~~ | | | uint32_t {aka unsigned int} In file included from src/near.h:36, from src/tag.c:35: src/tag.c: In function ‘near_tag_set_nfcid’: ./include/near/log.h:45:14: error: format ‘%zd’ expects argument of type ‘signed size_t’, but argument 4 has type ‘size_t’ {aka ‘long unsigned int’} [-Werror=format=] 45 | near_debug("%s:%s() " fmt, \ | ^~~~~~~~~~ src/tag.c:791:2: note: in expansion of macro ‘DBG’ 791 | DBG("NFCID len %zd", nfcid_len); | ^~~ Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-07-19snep-send: fix near_ndef_message memory leakKrzysztof Kozlowski1-0/+2
The result of near_ndef_prepare_text_record() should be freed, otherwise it leaks making ASAN and valgrind unhappy. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-07-19gdbus: annotate printf-like functions as accepting formatKrzysztof Kozlowski2-5/+11
Printf-like functions should have the "format" argument annotated to: 1. Help in detection of format string vulnerabilities (and mistakes). 2. Satisfy -Wformat-nonliteral (-Wformat=2) warning. This fixes clang warnings like: gdbus/object.c:1416:31: error: format string is not a string literal [-Werror,-Wformat-nonliteral] vsnprintf(str, sizeof(str), format, args); ^~~~~~ src/adapter.c:255:7: error: format string is not a string literal (potentially insecure) [-Werror,-Wformat-security] strerror(err)); ^~~~~~~~~~~~~ src/adapter.c:255:7: note: treat the string as an argument to avoid this strerror(err)); ^ "%s", Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-07-19netlink: use proper format for integers (-Wformat)Krzysztof Kozlowski1-8/+8
Properly print signed and unsigned integers. This fixes warnings like: src/netlink.c: In function ‘nfc_netlink_event_tm_deactivated’: ./include/near/log.h:45:14: error: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘uint32_t’ {aka ‘unsigned int’} [-Werror=format=] 45 | near_debug("%s:%s() " fmt, \ | ^~~~~~~~~~ src/netlink.c:759:2: note: in expansion of macro ‘DBG’ 759 | DBG("%d", idx); | ^~~ src/netlink.c: In function ‘nfc_netlink_event’: src/netlink.c:772:54: error: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘__u32’ {aka ‘unsigned int’} [-Werror=format=] 772 | near_error("WARNING: Wrong netlink message sender %d", | ~^ | | | int | %d 773 | src->nl_pid); | ~~~~~~~~~~~ | | | __u32 {aka unsigned int} Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-07-19manager: use proper format for integers (-Wformat)Krzysztof Kozlowski1-2/+2
Properly print signed and unsigned integers. This fixes warnings like: In file included from src/near.h:36, from src/manager.c:34: src/manager.c: In function ‘__near_manager_adapter_add’: ./include/near/log.h:45:14: error: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘uint32_t’ {aka ‘unsigned int’} [-Werror=format=] 45 | near_debug("%s:%s() " fmt, \ | ^~~~~~~~~~ src/manager.c:45:2: note: in expansion of macro ‘DBG’ 45 | DBG("idx %d", idx); | ^~~ Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-07-19device: use proper format for integers (-Wformat)Krzysztof Kozlowski1-3/+3
Properly print signed and unsigned integers. This fixes warnings like: src/device.c: In function ‘near_device_get_device’: src/device.c:85:33: error: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘uint32_t’ {aka ‘unsigned int’} [-Werror=format=] 85 | path = g_strdup_printf("%s/nfc%d/device%d", NFC_PATH, | ~^ | | | int | %d 86 | adapter_idx, target_idx); | ~~~~~~~~~~~ | | | uint32_t {aka unsigned int} Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-07-19npp: use proper format for integers (-Wformat)Krzysztof Kozlowski1-1/+1
Properly print signed and unsigned integers. This fixes warnings like: In file included from plugins/npp.c:36: plugins/npp.c: In function ‘npp_push’: ./include/near/log.h:45:14: error: format ‘%zd’ expects argument of type ‘signed size_t’, but argument 4 has type ‘size_t’ {aka ‘long unsigned int’} [-Werror=format=] 45 | near_debug("%s:%s() " fmt, \ | ^~~~~~~~~~ plugins/npp.c:185:2: note: in expansion of macro ‘DBG’ 185 | DBG("Sending %zd bytes", frame_length); | ^~~ Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-07-19p2p: use proper format for integers (-Wformat)Krzysztof Kozlowski1-2/+2
Properly print signed and unsigned integers. This fixes warnings like: In file included from plugins/p2p.c:38: plugins/p2p.c: In function ‘p2p_listener_event’: ./include/near/log.h:45:14: error: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘__u32’ {aka ‘unsigned int’} [-Werror=format=] 45 | near_debug("%s:%s() " fmt, \ | ^~~~~~~~~~ plugins/p2p.c:261:2: note: in expansion of macro ‘DBG’ 261 | DBG("target idx %d", client_addr.target_idx); | ^~~ Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-07-19mifare: use unsigned int to suppress compiler -Wstrict-overflowKrzysztof Kozlowski1-3/+3
GCC v7.5 (Ubuntu Bionic) with optimizations has trouble spotting lack of possible overflow of a signed integer. There is no overflow possible so this is a false positive which can be suppressed by simply using unsigned integer. Unsigned also has more sense in that context. This fixes GCC 7.5 warning: plugins/mifare.c: In function 'mifare_process_MADs': plugins/mifare.c:626:5: error: assuming signed overflow does not occur when simplifying conditional to constant [-Werror=strict-overflow] if (global_tag_size == 0) { ^ Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-07-19mifare: use proper format for integers (-Wformat)Krzysztof Kozlowski1-4/+4
Properly print signed and unsigned integers. This fixes warnings like: plugins/mifare.c: In function ‘mifare_read’: plugins/mifare.c:836:33: error: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘unsigned int’ [-Werror=format=] 836 | near_error("Mifare tag type [%d] not supported.", tgt_subtype); | ~^ ~~~~~~~~~~~ | | | | int unsigned int | %d Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-07-19nfctype5: fix returning uninitialized stack value in t5_tag_is_ti_pro()Krzysztof Kozlowski1-1/+1
The return value was not initialized so if tag was not matching, random stack value (usually true) was returned instead of false. This fixes clang warning: plugins/nfctype5.c:257:6: error: variable 'ret' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized] if ((uid[5] == 0xc4) || (uid[5] == 0xc5)) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ plugins/nfctype5.c:261:9: note: uninitialized use occurs here return ret; ^~~ plugins/nfctype5.c:257:2: note: remove the 'if' if its condition is always true if ((uid[5] == 0xc4) || (uid[5] == 0xc5)) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ plugins/nfctype5.c:248:10: note: initialize the variable 'ret' to silence this warning bool ret; ^ = false Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-07-19nfctype5: use proper format for integers (-Wformat)Krzysztof Kozlowski1-3/+3
Properly print signed and unsigned integers. This fixes warnings like: In file included from plugins/nfctype5.c:29: plugins/nfctype5.c: In function ‘t5_read’: ./include/near/log.h:45:14: error: format ‘%zd’ expects argument of type ‘signed size_t’, but argument 4 has type ‘size_t’ {aka ‘long unsigned int’} [-Werror=format=] 45 | near_debug("%s:%s() " fmt, \ | ^~~~~~~~~~ plugins/nfctype5.c:437:2: note: in expansion of macro ‘DBG’ 437 | DBG("Reading %zd bytes starting at offset %d\n", len, offset); | ^~~ Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-07-19nfctype3: use proper format for integers (-Wformat)Krzysztof Kozlowski1-1/+1
Properly print signed and unsigned integers. This fixes warnings like: In file included from plugins/nfctype3.c:36: plugins/nfctype3.c: In function ‘data_recv’: ./include/near/log.h:45:14: error: format ‘%zd’ expects argument of type ‘signed size_t’, but argument 4 has type ‘size_t’ {aka ‘long unsigned int’} [-Werror=format=] 45 | near_debug("%s:%s() " fmt, \ | ^~~~~~~~~~ plugins/nfctype3.c:249:3: note: in expansion of macro ‘DBG’ 249 | DBG("Done reading %zd bytes at %p", data_length, nfc_data); | ^~~ Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-07-19nfctype2: use proper format for integers (-Wformat)Krzysztof Kozlowski1-6/+6
Properly print signed and unsigned integers. This fixes warnings like: In file included from plugins/nfctype2.c:36: plugins/nfctype2.c: In function ‘data_recv’: ./include/near/log.h:45:14: error: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘uint32_t’ {aka ‘unsigned int’} [-Werror=format=] 45 | near_debug("%s:%s() " fmt, \ | ^~~~~~~~~~ plugins/nfctype2.c:195:2: note: in expansion of macro ‘DBG’ 195 | DBG("adapter %d", adapter_idx); | ^~~ plugins/nfctype2.c: In function ‘nfctype2_write’: plugins/nfctype2.c:458:43: error: format ‘%zd’ expects argument of type ‘signed size_t’, but argument 2 has type ‘size_t’ {aka ‘long unsigned int’} [-Werror=format=] 458 | near_error("Not enough space on tag %zd %zd", | ~~^ | | | long int | %ld 459 | ndef->length, | ~~~~~~~~~~~~ | | | size_t {aka long unsigned int} Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-07-19bluetooth: use proper format for integers (-Wformat)Krzysztof Kozlowski1-2/+2
Properly print signed and unsigned integers. This fixes warnings like: In file included from src/near.h:36, from src/bluetooth.c:32: src/bluetooth.c: In function ‘bt_adapter_property_changed’: ./include/near/log.h:45:14: error: format ‘%x’ expects argument of type ‘unsigned int’, but argument 5 has type ‘int’ [-Werror=format=] 45 | near_debug("%s:%s() " fmt, \ | ^~~~~~~~~~ src/bluetooth.c:465:3: note: in expansion of macro ‘DBG’ 465 | DBG("%s: %x", property, bt_def_oob_data.class_of_device); | ^~~ In file included from src/near.h:36, from src/bluetooth.c:32: src/bluetooth.c: In function ‘bt_adapter_property_changed’: ./include/near/log.h:45:14: error: format ‘%u’ expects argument of type ‘unsigned int’, but argument 5 has type ‘int’ [-Werror=format=] 45 | near_debug("%s:%s() " fmt, \ | ^~~~~~~~~~ src/bluetooth.c:475:3: note: in expansion of macro ‘DBG’ 475 | DBG("%s: %u", property, bt_def_oob_data.powered); | ^~~ Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-07-19nciattach: do not shadow other local 'opt' variable (-Wshadow)Krzysztof Kozlowski1-4/+4
Fix -Wshadow warning: tools/nciattach.c: In function ‘main’: tools/nciattach.c:272:9: error: declaration of ‘opt’ shadows a previous local [-Werror=shadow] 272 | char *opt; | ^~~ tools/nciattach.c:236:24: note: shadowed declaration is here 236 | int detach, printpid, opt, i, n, ld, err; | ^~~ Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-07-19nciattach: fix poll.h include locationKrzysztof Kozlowski1-1/+1
poll.h header should not be included from include/sys. This works fine on Glibc but fails on musl: In file included from tools/nciattach.c:42: /usr/include/sys/poll.h:1:2: error: #warning redirecting incorrect #include <sys/poll.h> to <poll.h> [-Werror=cpp] 1 | #warning redirecting incorrect #include <sys/poll.h> to <poll.h> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-07-19gdbus: do not shadow global 'pending' variable (-Wshadow)Krzysztof Kozlowski1-11/+11
Fix -Wshadow warnings: gdbus/object.c: In function ‘g_dbus_pending_success’: gdbus/object.c:286:24: error: declaration of ‘pending’ shadows a global declaration [-Werror=shadow] 286 | GDBusPendingReply pending) | ~~~~~~~~~~~~~~~~~~^~~~~~~ gdbus/object.c:89:16: note: shadowed declaration is here 89 | static GSList *pending = NULL; | ^~~~~~~ gdbus/object.c: In function ‘g_dbus_pending_error_valist’: gdbus/object.c:308:23: error: declaration of ‘pending’ shadows a global declaration [-Werror=shadow] 308 | GDBusPendingReply pending, const char *name, | ~~~~~~~~~~~~~~~~~~^~~~~~~ gdbus/object.c:89:16: note: shadowed declaration is here 89 | static GSList *pending = NULL; | ^~~~~~~ gdbus/object.c: In function ‘g_dbus_pending_error’: gdbus/object.c:331:23: error: declaration of ‘pending’ shadows a global declaration [-Werror=shadow] 331 | GDBusPendingReply pending, | ~~~~~~~~~~~~~~~~~~^~~~~~~ gdbus/object.c:89:16: note: shadowed declaration is here 89 | static GSList *pending = NULL; | ^~~~~~~ gdbus/object.c: In function ‘builtin_security_function’: gdbus/object.c:370:25: error: declaration of ‘pending’ shadows a global declaration [-Werror=shadow] 370 | GDBusPendingReply pending) | ~~~~~~~~~~~~~~~~~~^~~~~~~ gdbus/object.c:89:16: note: shadowed declaration is here 89 | static GSList *pending = NULL; | ^~~~~~~ Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-07-19adapter: use proper format for integers (-Wformat)Krzysztof Kozlowski1-14/+14
Properly print signed and unsigned integers. This fixes warnings like: src/adapter.c: In function ‘near_adapter_disconnect’: ./include/near/log.h:45:14: error: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘uint32_t’ {aka ‘unsigned int’} [-Werror=format=] 45 | near_debug("%s:%s() " fmt, \ | ^~~~~~~~~~ src/adapter.c:1095:2: note: in expansion of macro ‘DBG’ 1095 | DBG("idx %d", idx); | ^~~ Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-07-19adapter: adjust indentation of continued argumentsKrzysztof Kozlowski1-6/+6
No functional change. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-07-19se: use proper format for integers (-Wformat)Krzysztof Kozlowski5-29/+29
Properly print signed and unsigned integers. This fixes warnings like: In file included from se/plugins/nfc.c:37: se/plugins/nfc.c: In function ‘nfc_netlink_event_se’: ./include/near/log.h:45:14: error: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘uint32_t’ {aka ‘unsigned int’} [-Werror=format=] 45 | near_debug("%s:%s() " fmt, \ | ^~~~~~~~~~ se/plugins/nfc.c:200:2: note: in expansion of macro ‘DBG’ 200 | DBG("NFC %d SE %d", nfc_idx, se_idx); | ^~~ se/plugins/nfc.c:270:2: note: in expansion of macro ‘DBG’ 270 | DBG("NFC %d SE %d APDU len %zd", nfc_idx, se_idx, apdu_len); | ^~~ ./include/near/log.h:45:14: error: format ‘%zd’ expects argument of type ‘signed size_t’, but argument 6 has type ‘size_t’ {aka ‘long unsigned int’} [-Werror=format=] 45 | near_debug("%s:%s() " fmt, \ | ^~~~~~~~~~ In file included from se/../src/near.h:36, from se/seel.h:29, from se/se.c:34: se/se.c: In function ‘io_cb’: ./include/near/log.h:45:14: error: format ‘%zd’ expects argument of type ‘signed size_t’, but argument 4 has type ‘size_t’ {aka ‘long unsigned int’} [-Werror=format=] 45 | near_debug("%s:%s() " fmt, \ | ^~~~~~~~~~ se/se.c:119:2: note: in expansion of macro ‘DBG’ 119 | DBG("%zd %d", apdu_length, err); | ^~~ se/se.c: In function ‘se_path’: se/se.c:250:43: error: format ‘%d’ expects argument of type ‘int’, but argument 6 has type ‘uint32_t’ {aka ‘unsigned int’} [-Werror=format=] 250 | return g_strdup_printf("%s/se/%s%d_%s_se%d", SEEL_PATH, | ~^ | | | int | %d 251 | ctrl, ctrl_idx, type, se_idx); | ~~~~~~ | | | uint32_t {aka unsigned int} Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-07-19se: silence clang -Wcast-align warningKrzysztof Kozlowski1-3/+27
Fix clang warnings: se/ace.c:147:15: error: cast from 'uint8_t *' (aka 'unsigned char *') to 'struct seel_ace_apdu_rule *' increases required alignment from 1 to 4 [-Werror,-Wcast-align] apdu_rule = (struct seel_ace_apdu_rule *)rule->apdu_rules; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ se/ace.c:790:18: error: cast from 'uint8_t *' (aka 'unsigned char *') to 'uint32_t *' (aka 'unsigned int *') increases required alignment from 1 to 4 [-Werror,-Wcast-align] apdu_header = *((uint32_t *) apdu); ^~~~~~~~~~~~~~~~~ se/ace.c:791:14: error: cast from 'uint8_t *' (aka 'unsigned char *') to 'struct seel_ace_apdu_rule *' increases required alignment from 1 to 4 [-Werror,-Wcast-align] apdu_rule = (struct seel_ace_apdu_rule *)rule->apdu_rules; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Increasing alignment should be fine for most of the platforms (maybe except some performance penalty), although there are such which might not handle it and raise CPU exception. I am not sure whether the code is actually safe, but proper fixing would require bigger changes. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-07-19se: fix multiple apdu definitionsKrzysztof Kozlowski1-1/+1
Fixes: /usr/bin/ld: se/seeld-manager.o:se/seel.h:31: multiple definition of `apdu'; se/seeld-main.o:se/seel.h:31: first defined here /usr/bin/ld: se/seeld-se.o:se/seel.h:31: multiple definition of `apdu'; se/seeld-main.o:se/seel.h:31: first defined here /usr/bin/ld: se/seeld-driver.o:se/seel.h:31: multiple definition of `apdu'; se/seeld-main.o:se/seel.h:31: first defined here /usr/bin/ld: se/seeld-apdu.o:se/seel.h:31: multiple definition of `apdu'; se/seeld-main.o:se/seel.h:31: first defined here /usr/bin/ld: se/seeld-channel.o:se/seel.h:31: multiple definition of `apdu'; se/seeld-main.o:se/seel.h:31: first defined here /usr/bin/ld: se/seeld-ace.o:se/seel.h:31: multiple definition of `apdu'; se/seeld-main.o:se/seel.h:31: first defined here Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-07-19ndef: make freeing near_ndef_message reusableKrzysztof Kozlowski2-28/+29
In few places the ndef record/message (struct near_ndef_message) is allocated and not freed leading to memory leaks. In few places it is also open-coded. Rename free_ndef_message() to near_ndef_msg_free() and allow other parts to use it. No functional change, except global symbol. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-07-19ndef: use proper format for integers (-Wformat)Krzysztof Kozlowski1-6/+6
Properly print signed and unsigned integers. This fixes warnings like: ./include/near/log.h:45:14: error: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘uint32_t’ {aka ‘unsigned int’} [-Werror=format=] 45 | near_debug("%s:%s() " fmt, \ | ^~~~~~~~~~ src/ndef.c:1084:2: note: in expansion of macro ‘DBG’ 1084 | DBG("payload length %d", rec_header->payload_len); | ^~~ Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-07-19ndef: use NDEF_TEXT_RECORD_UTF16_STATUS defineKrzysztof Kozlowski1-2/+2
Don't hard-code 0x80 because there is a define for it. No functional change. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-07-19ndef: silence clang -Wcast-align warningKrzysztof Kozlowski1-1/+2
Fix clang warning: src/ndef.c:1196:28: error: cast from 'char *' to 'gunichar2 *' (aka 'unsigned short *') increases required alignment from 1 to 2 [-Werror,-Wcast-align] g_str = g_utf16_to_utf8((gunichar2 *)txt, len, NULL, ^~~~~~~~~~~~~~~~ The case is safe as length of string is an even number. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-07-19ndef: check UTF-16 text payload lengthKrzysztof Kozlowski2-0/+24
UTF-16 is supposed to be consisting of 16-bit codes (16-bit or 2x16-bit per character) and parsing anything else is not safe because of cast to gunichar2. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-07-19unit: pass real UTF-8 for testing text NDEFKrzysztof Kozlowski1-4/+5
Let's polish this UTF-8. :) Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-07-19dbus: fix -Wformat in near_dbus_encode_string()Krzysztof Kozlowski1-1/+1
Fix GCC warning: src/dbus.c: In function ‘near_dbus_encode_string’: src/dbus.c:71:37: error: format ‘%x’ expects argument of type ‘unsigned int’, but argument 3 has type ‘int’ [-Werror=format=] 71 | g_string_append_printf(str, "_%02x", tmp); | ~~~^ ~~~ | | | | | int | unsigned int | %02x Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-07-19nfctool: pass the format as string literalKrzysztof Kozlowski1-4/+4
clang v11 has troubles detecting that sprintf() format is passed in sniffer_print_hexdump() as string literal. Remove the local "fmt" variable and call sprintf() in two branches of if, to satisfy clang and fix warnings like: tools/nfctool/sniffer.c:206:18: error: format string is not a string literal [-Werror,-Wformat-nonliteral] sprintf(line, fmt, offset); ^~~ Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-07-19nfctool: use proper format for integers (-Wformat)Krzysztof Kozlowski4-15/+15
Properly print igned and nsigned integers. This fixes warnings like: In file included from tools/nfctool/main.c:37: tools/nfctool/main.c: In function ‘nfctool_start_poll’: tools/nfctool/main.c:73:15: error: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘guint32’ {aka ‘unsigned int’} [-Werror=format=] 73 | print_error("Invalid adapter index: %d", opts.adapter_idx); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~ | | | guint32 {aka unsigned int} tools/nfctool/llcp-decode.c: In function ‘llcp_print_params’: tools/nfctool/llcp-decode.c:276:27: error: format ‘%X’ expects argument of type ‘unsigned int’, but argument 3 has type ‘int’ [-Werror=format=] 276 | sprintf(param_str, "0x%X", param[2] & 0x03); | ~^ ~~~~~~~~~~~~~~~ | | | | unsigned int int | %X tools/nfctool/llcp-decode.c: In function ‘llcp_print_pdu’: tools/nfctool/llcp-decode.c:553:27: error: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 4 has type ‘__time_t’ {aka ‘long int’} [-Werror=format=] 553 | sprintf(time_str, "%c%lu.%06lus", prefix, msg_timestamp.tv_sec, | ~~^ ~~~~~~~~~~~~~~~~~~~~ | | | | long unsigned int __time_t {aka long int} | %lu Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-07-19nfctool: fix nfctool_print_and_remove_snl() cast-function-typeKrzysztof Kozlowski1-2/+2
Fix on GCC v10: tools/nfctool/main.c: In function ‘nfctool_snl_cb’: tools/nfctool/main.c:352:30: error: cast between incompatible function types from ‘void (*)(struct nfc_snl *, guint32)’ {aka ‘void (*)(struct nfc_snl *, unsigned int)’} to ‘void (*)(void *, void *)’ [-Werror=cast-function-type] 352 | g_slist_foreach(sdres_list, (GFunc)nfctool_print_and_remove_snl, | ^ Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-07-19nfctool: fix nfctool_send_dep_link_up() cast-function-typeKrzysztof Kozlowski1-2/+2
Fix on GCC v10: tools/nfctool/main.c: In function ‘nfctool_targets_found’: tools/nfctool/main.c:294:5: error: cast between incompatible function types from ‘void (*)(guint32, guint32)’ {aka ‘void (*)(unsigned int, unsigned int)’} to ‘void (*)(void *, void *)’ [-Werror=cast-function-type] 294 | (GFunc)nfctool_send_dep_link_up, | ^ Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-07-19nfctool: fix adapter_compare_idx() cast-function-typeKrzysztof Kozlowski1-2/+4
Fix on GCC v10: tools/nfctool/adapter.c: In function ‘adapter_get’: tools/nfctool/adapter.c:155:8: error: cast between incompatible function types from ‘gint (*)(struct nfc_adapter *, guint32)’ {aka ‘int (*)(struct nfc_adapter *, unsigned int)’} to ‘gint (*)(const void *, const void *)’ {aka ‘int (*)(const void *, const void *)’} [-Werror=cast-function-type] 155 | (GCompareFunc)adapter_compare_idx); | ^ Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-07-19nfctool: fix adapter_print_info() cast-function-typeKrzysztof Kozlowski3-4/+4
Fix on GCC v10: tools/nfctool/adapter.c: In function ‘adapter_idx_print_info’: tools/nfctool/adapter.c:139:29: error: cast between incompatible function types from ‘void (*)(struct nfc_adapter *)’ to ‘void (*)(void *, void *)’ [-Werror=cast-function-type] 139 | g_slist_foreach(adapters, (GFunc)adapter_print_info, NULL); | ^ Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-07-19nfctool: fix adapter_print_target() cast-function-typeKrzysztof Kozlowski1-2/+2
Fix on GCC v10: tools/nfctool/adapter.c: In function ‘adpater_print_targets’: tools/nfctool/adapter.c:69:33: error: cast between incompatible function types from ‘void (*)(guint32, gchar *)’ {aka ‘void (*)(unsigned int, char *)’} to ‘void (*)(void *, void *)’ [-Werror=cast-function-type] 69 | g_slist_foreach(adapter->tags, (GFunc)adapter_print_target, "tag"); | ^ Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-07-19nfctool: fix adapter_get_devices() cast-function-typeKrzysztof Kozlowski1-1/+1
Fix on GCC v10: tools/nfctool/adapter.c: In function ‘adapter_all_get_devices’: tools/nfctool/adapter.c:55:28: error: cast between incompatible function types from ‘void (*)(struct nfc_adapter *)’ to ‘void (*)(void *, void *)’ [-Werror=cast-function-type] 55 | g_slist_foreach(adapters, (GFunc)adapter_get_devices, NULL); | ^ Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-07-19Drop empty NEWSKrzysztof Kozlowski1-0/+0
There are no news. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2017-11-10test: Add option to deactivate tagMark Greer1-0/+13
Add the 'deactivate' option to test-tag which deactivates the specified tag. Signed-off-by: Mark Greer <mgreer@animalcreek.com>
2017-11-10tag: Add Tag deactivate supportMark Greer5-0/+73
Once a tag has been discovered, it remains active until it is moved out of range, or an error occurs while reading or writing it. While the tag is active, the adapter cannot be powered off. This wastes power when the client application no longer cares whether the tag is in range or not. To address this issue, add the ability for a client application to deactivate an active tag. Once deactivated, the client application can poll the tag again to read it or power off the adapter. The 'NFC_CMD_DEACTIVATE_TARGET' netlink command is added to request that the kernel deactivate the target (tag). Signed-off-by: Mark Greer <mgreer@animalcreek.com>
2017-11-10adapter: Add call indicating whether constant poll is enabledMark Greer2-0/+6
Add a routine that returns a boolean indicating whether the adapter constant poll option is enabled or not. Signed-off-by: Mark Greer <mgreer@animalcreek.com>
2017-11-10adapter: Make adapter_start_poll() globalMark Greer2-11/+12
An upcoming commit will need to call adapter_start_poll() from the tag code so make it global. To be consistent with the names of other global routines in adapter.c, add the '__near_' prefix. Signed-off-by: Mark Greer <mgreer@animalcreek.com>
2017-11-10nfc_copy: Update nfc_copy.h to match Linux kernel's versionMark Greer3-26/+51
neard's version of Linux's include/uapi/linux/nfc.h file has become stale so update it to match the most current. The update changes a few macro names which are used by neard so update those names in the neard code as well. Signed-off-by: Mark Greer <mgreer@animalcreek.com>
2017-11-10nfctools: Move nciattach macros & enums to nciattach.cMark Greer2-12/+12
Some header file macros and an enum were copied from Linux and placed in neard's include/nfc_copy.h file. That isn't the proper place as nfc_copy.h is supposed to be a pristine copy of the Linux nfc.h file. Move those header file definitions into tools/nciattach.c since that is the only file that uses them. Signed-off-by: Mark Greer <mgreer@animalcreek.com>
2017-11-10nfctype5: Fix formattingMark Greer1-60/+58
Use the output of the Linux kernel's 'Lindent' script to format the code in nfctype5.c. Some of the formatting performed by Lindent was overridden for various reasons. These include: - no space between '__attribute__' and '((packed))' to match other tag files - struct members names are aligned when defined for readability - compile-time init of struct members are aligned for readability - call arguments not lined up when result would cause lines with more than 80 characters - no spaces around ampersand when casting address of a variable - no space between '*' and name in declarations/definitions Signed-off-by: Mark Greer <mgreer@animalcreek.com>
2017-11-10nfctype5: Discard extra byte in RMB response dataMark Greer1-3/+10
Sometimes there can be an extra byte in the response data for Read Multiple Blocks (RMB) commands so discard it whenever that happens. Signed-off-by: Mark Greer <mgreer@animalcreek.com>
2017-11-10nfctype5: Don't issue RMB command when formattingMark Greer1-53/+24
Currently, when neard is formatting a Type 5 tag, it issues the Read Multiple Blocks (RMB) command to see if the tag supports it. If the command succeeds, the appropriate bit in the CC is set so the RMB command can be used in the future. The problem is that when the tag doesn't support the command, a failure is returned by the kernel causing the neard adapter code to disconnect from the tag. This effectively makes the tag unusable by neard. To avoid this issue, don't bother checking to see if the RMB command is supported and just assume that it isn't (and therefore, do not set the MBREAD bit in the CC). This has the benefit of formatting Type 5 tags that don't support RMB at the cost of forcing future readers to use a series of Read Single Block commands for multi-block reads (i.e., slower than a single multi-block read). Signed-off-by: Mark Greer <mgreer@animalcreek.com>
2017-11-10nfctype5: Remove useless initializationMark Greer1-2/+2
There is no point in assigning 'local_data' to 'cookie' when 'cookie' is going to be reassigned before it is used. Signed-off-by: Mark Greer <mgreer@animalcreek.com>
2017-11-10nfctype5: Add support for TI Standard and Pro Type 5 tagMark Greer1-2/+59
Standard and Pro Type 5 tags from Texas Instruments do not support the Get System Information command which means they cannot be read with the current neard code. Fortunately, both types of tags have eight, 4-byte blocks so that information can be filled in instead of issuing the Get System Information command to get it. With this change, Standard and Pro tags can now be formatted, read, and written. Signed-off-by: Mark Greer <mgreer@animalcreek.com>
2017-11-10nfctype5: Rework code that identifies ST Micro Type 5 tagsMark Greer1-24/+27
Rework the code that identifies ST Micro Type 5 tags to make it conform better to established coding style in the file and to make it easier to add check for tags from other manufacturers. Signed-off-by: Mark Greer <mgreer@animalcreek.com>
2017-11-10nfctype5: Remove superfluous parenthesesMark Greer1-3/+3
Remove the superfluous parentheses around calls to t5_manufacturer_stmicro(). Signed-off-by: Mark Greer <mgreer@animalcreek.com>
2017-11-10nfctype5: Add space between 'if' and first '('Mark Greer1-3/+3
Add a space between the 'if' and first parenthesis in 'if' statements as no space is both annoying and contrary to neard coding style. Signed-off-by: Mark Greer <mgreer@animalcreek.com>
2017-11-10nfctype5: Reduce noise when tag is moved out of rangeMark Greer1-1/+1
The NFC Type 5 tag code prints a message whenever it receives an error. This makes it extra noisy compared to the other tag types whenever a tag is moved out of range. Instead, reduce that noise by turning the error message into a debug message. Signed-off-by: Mark Greer <mgreer@animalcreek.com>
2017-11-10nfctype2: Don't read tags with bad magic numberMark Greer1-0/+1
NFC Type 2 tags that have a bad magic number need to be reformatted so do not try to read them. Signed-off-by: Mark Greer <mgreer@animalcreek.com>
2017-11-10adapter: Do not poll when there is an active tagMark Greer1-0/+3
When there is an active tag and a request to start polling is received by neard, it will discard the currently registered tag and requests that the kernel start another poll. The kernel receives this request and returns EBUSY because there is already an active tag. neard receives this failure and reports it to the poll requestor. At this point, the tag is active but neard no longer has any knowledge of it. Fix this by returning EBUSY when there is an active tag and a new poll request is received. Signed-off-by: Mark Greer <mgreer@animalcreek.com>
2017-11-10adapter: Clear timer handle when DEP timer stoppedMark Greer1-1/+3
__near_adapter_set_dep_state() stops the neard DEP timer but doesn't clear the timer handle. This can cause neard to try to stop the timer when it isn't running. To fix that, clear the handle so neard doesn't try to stop an already stopped timer. Signed-off-by: Mark Greer <mgreer@animalcreek.com>
2017-11-10adapter: Clear timeout handle when check presence timer stoppedMark Greer1-1/+3
__near_adapter_stop_check_presence() stops the neard check presence timer but doesn't clear the timer handle. This can cause neard to try to stop the timer when it isn't running. To fix that, clear the handle so neard doesn't try to stop an already stopped timer. Signed-off-by: Mark Greer <mgreer@animalcreek.com>
2017-11-10adapter: Return '-errno' when connect() call failsMark Greer1-1/+1
near_adapter_connect() incorrectly returns '-1' when the connect() call fails. Instead, it should return '-errno' which is the real error code. Signed-off-by: Mark Greer <mgreer@animalcreek.com>
2017-11-10adapter: Return '-errno' when socket() call failsMark Greer1-1/+1
near_adapter_connect() incorrectly returns '-1' when the socket() call fails. Instead, it should return '-errno' which is the real error code. Signed-off-by: Mark Greer <mgreer@animalcreek.com>
2017-11-10ndef: Validate text data in WKT Text recordsMark Greer1-4/+23
Ensure that the text encodings in WKT Text records are valid. Signed-off-by: Mark Greer <mgreer@animalcreek.com>
2017-11-10ndef: Discard records containing errorsMark Greer1-1/+2
Currently, near_ndef_parse_msg() adds records even when they contain erroneous record types. This can later cause neard to exit when it tries to signal dbus with incomplete record information. Avoid this by ignoring records that contain bad record types (and all of the records that follow in the same NDEF message). Signed-off-by: Mark Greer <mgreer@animalcreek.com>
2017-11-10ndef: Verify RTD record type name encodingsMark Greer1-0/+7
The NFC Forum's Record Type Definition (RTD) Technical Specification version 1.0, section 3.4 (RTD Type Names Requirements) specifies that RTD type name encodings MUST be done according to the ASCII chart in Appendix A (Character Set for Record Types). Enforce this by checking that all of the RTD type name encodings are valid before determining their type. Conveniently, isprint() does the correct checking. Signed-off-by: Mark Greer <mgreer@animalcreek.com>
2017-11-10ndef: Fix use of uninitialized variable in property_get_type()Mark Greer1-0/+1
The 'type' variable in property_get_type() is never set when the record type is invalid. This means that the check for NULL doesn't work as it should and a bogus string can be appended. Fix this by adding a default case to the switch statement that checks the record type ensuring that 'type' is set to NULL when the record type is invalid. Signed-off-by: Mark Greer <mgreer@animalcreek.com>
2017-11-10ndef: Add default language ("en") for Text recordsMark Greer1-1/+4
Despite section 3.3 of the NFC Forum RTD-Text 1.0 Technical Specification stating in part, "The language code MAY NOT be omitted", some tags have a 0-length language field. A 0-length language field currently causes neard to exit which isn't ideal so choose a default language (generic English) which will be used in these situations. There is no particular reason to choose English other than it is the native language of the patch author and it is the language neard is coded in. Signed-off-by: Mark Greer <mgreer@animalcreek.com> --- This is identical to an earlier patch submitted to the linux-nfc mail list in October (link below) so that patch can be discarded. https://lists.01.org/pipermail/linux-nfc/2016-October/004292.html
2017-07-22se: Fix issue with missing fall through handlingMarcel Holtmann1-0/+1
2017-07-22nfctype2: Use explicit comparison to zero to make it clearerMarcel Holtmann1-1/+1
plugins/nfctype2.c:68:38: error: ‘*’ in boolean context, suggest ‘&&’ instead [-Werror=int-in-bool-context] #define TAG_DATA_LENGTH(cc) ((cc)[2] * 8) ~~~~~~~~~^~~~ plugins/nfctype2.c:245:11: note: in expansion of macro ‘TAG_DATA_LENGTH’ NULL, (TAG_DATA_LENGTH(cc) ? TAG_DATA_LENGTH(cc) : ^~~~~~~~~~~~~~~
2017-07-22ndef: Fix missing handling of fall through caseMarcel Holtmann1-1/+2
2017-07-22nfctool: Add missing fall through commentMarcel Holtmann1-0/+1
2016-07-04Release 0.160.16Samuel Ortiz2-1/+13
2016-07-04nfctool: polling: Fix netlink event handlerThierry Escande1-0/+3
With this patch, the netlink event handler for poll operations now only treats messages from the device specified with the -d command line parameter. This fixes an issue when used with nfcsim (the loopback driver) for which you have 2 instances of nfctool running simultaneously in poll mode. Both instances were receiving the TARGETS_FOUND and TM_ACTIVATED events which could lead to prematurely stop the poll operation for the target device. Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2016-03-29doc: Describe writing of the multiple recordsOleg Zhurakivskyy1-0/+7
2016-03-29ndef: Handle multi-record messagesOleg Zhurakivskyy1-11/+29
A special care is taken of SmartPoster and Handover messages, since they are multi-record. Currently they are supported only in the single record mode of the tag.write() method.
2016-03-29ndef: Handle multiple recordsOleg Zhurakivskyy1-4/+52
In case multiple records are discovered, they are joined together. The bit flags MB (Message Begin), ME (Message End) in the first byte of each record header are set/reset accordingly.
2016-03-29ndef: Parse multiple records from the D-Bus messageOleg Zhurakivskyy1-2/+80
The dictionary entry "Records" indicates multiple records ("aa{sv}") in its value part. In case this entry is absent, we are dealing with the single record.
2016-03-29ndef: Reference the D-Bus message by iteratorOleg Zhurakivskyy1-20/+16
This is a preparation to support parsing of multiple records inside one D-Bus message.
2016-03-29ndef: Extract the record parsing into ndef_build_from_record()Oleg Zhurakivskyy1-7/+15
2016-03-29test: Add basic support for the multiple URI recordsOleg Zhurakivskyy1-3/+29
2016-03-29ndef: Fix the segmentation fault on non MIME recordsOleg Zhurakivskyy1-1/+2
2016-03-15features: Add Handover supportSamuel Ortiz1-1/+1
2016-03-13se/test/test-channel: Fix secure element pathChristophe Ricard1-1/+1
The secure element path is incorrect
2016-03-13se/test/test-seel: Fix secure element pathChristophe Ricard1-3/+3
The secure element path is incorrect
2016-03-13test/neard-ui.py: update test/neard-ui.pyChristophe Ricard1-104/+130
test/neard-ui.py was not working anymore since the transition to managed object. The script got recovered with few code style changes like using neardutils functions and variable when possible.
2016-03-13test/neardutils: Few sanity cleanupChristophe Ricard1-4/+4
org.neard and org.neard.Record have their own variable SERVICE_NAME and RECORD_INTERFACE.
2016-03-13se: Return true if ARA-M is not accessible on a non uicc SEChristophe Ricard3-1/+22
According to GP specification, an eSE should be accessible when the ARA-M is not accessible.
2016-03-13doc: Add MIMEPayload to tag's propertiesOleg Zhurakivskyy1-0/+5
2016-03-13ndef: Expose MIME payloadOleg Zhurakivskyy1-5/+49
2016-03-13test: Support arbitrary MIME contentOleg Zhurakivskyy1-1/+5
2016-02-22AUTHORS: Mention Oleg's contributionsSamuel Ortiz1-0/+1
2016-02-22build: Fix nciattach distcheck failureSamuel Ortiz1-1/+1
nciattach includes near.h so we need to use the right include path.
2016-02-21ndef: Minor whitespace correctionsOleg Zhurakivskyy1-2/+2
2016-02-21test: Simplify MIME parameters parsingOleg Zhurakivskyy1-11/+22
2016-02-21test: Clean up help textOleg Zhurakivskyy1-22/+26
2016-02-21test: Remove unneeded codeOleg Zhurakivskyy1-7/+0
2016-02-21test: Fix indentationOleg Zhurakivskyy1-17/+16
2016-02-21build: Add Python bytecode to .gitignoreOleg Zhurakivskyy1-0/+1
2016-02-21build: Add tools/nciattach to .gitignoreOleg Zhurakivskyy1-0/+1
2015-12-22nfctype5: Add support for ST Type5 tagsShikha Singh1-4/+43
Modification in nfctype5.c to support ST Type5 tags. CMD_FLAG_OPTION which is required to be set for TI flags does not work for ST tags. Neard's checking to test multiple block read feature of tag is not sufficient for ST tags. ST tags does not support multiple block read if block lies in different sectors. So, eliminating multi block read feature for ST tags.
2015-12-21test: Fix test-tage usageSamuel Ortiz1-7/+7
2015-08-22tools: Add nciattach toolVincent Cuissard3-1/+365
This tool is needed to configure NCI UART drivers.
2015-04-20gdbus: Close private connection if setup failsLuiz Augusto von Dentz1-0/+1
Private connection should be properly closed with dbus_connection_close otherwise libdbus exits with the following error: 'The last reference on a connection was dropped without closing the connection. This is a bug in an application. See dbus_connection_unref() documentation for details. Most likely, the application was supposed to call dbus_connection_close(), since this is a private connection.'
2015-04-09gdbus: Fix crash in g_dbus_create_error_valistSzymon Janc1-1/+4
Passing NULL format parameter to vsnprintf results in invalid argument error on glibc. But with some other libc libraries (musl and uClibc) this results in dereferencing NULL pointer and crash due to segmentation fault.
2015-04-09gdbus: Use g_dbus_create_error_valist internallySzymon Janc1-4/+1
There is no need to duplicate code in g_dbus_send_error_valist.
2015-04-07gdbus: Add g_dbus_get_flags functionMichael Janssen2-0/+6
The g_dbus_get_flags function enables detection of when the G_DBUS_FLAG_ENABLE_EXPERIMENTAL is set.
2015-03-27se: Fix status word management in case of warningChristophe Ricard1-0/+13
As per SIMAlliance_OpenMobileAPI3_0_release1_FINAL.pdf document The API shall handle received status word as follows: "If the status word indicates that the SE was able to open a channel (e.g status word '90 00' or status words referencing a warning in ISO-7816-4: '62 XX' or '63 XX') the API shall keep the channel opened and the next getSelectResponse() shall return the received status word."
2015-03-27se: Release logical channel when AID selection failsChristophe Ricard1-5/+30
When a select AID response status word is not 0x9000, the logical channel used to communicate with this application should be closed.
2015-03-27se: Add test-channel test scriptChristophe Ricard1-0/+64
Adding test-channel test script to manipulate channels on a specific secure element.
2015-03-27se: Add test-seel test scriptChristophe Ricard1-0/+114
Adding test-seel test script to manipulate secure element.
2015-03-26se: Handle previously enabled secure elementsChristophe Ricard1-1/+7
When seeld terminates but the devices does not reboot, the secure element may be already up when seeld re-starts. In that case, do not send an Enabled error, but gracefully fall back to the right enabled state.
2015-03-26se: Check for se's io_driver and transceive function pointersChristophe Ricard1-3/+3
A secure element may exist without any io_driver or without any transceive function.
2015-03-26se: Start access control enforcer (ACE) once SE is enabledChristophe Ricard1-2/+1
Before the SE is enabled, no APDUs can be sent to it. So it makes more sense to start doing access control check once the SE is actually enabled.
2015-03-26test: Use neardutils.get_managed_objects() when possibleChristophe Ricard3-15/+5
neardutils.get_managed_objects() is defined in neardutils.py but never used. It can perfectly fit at several places in test/test-adapter, test/test-device, test/test-tag
2015-03-26nfctype2: Fix Mifare Ultralight C issueChristophe Ricard1-2/+19
When a Mifare Ultralight C is read, accessing page address from range 44 to 47 (or 0x2c to 0x2f) will returns NAK on the RF interface. A normal read command results into 16bytes answer. Ref: MF0ICU2 Mifare Ultralight C.
2015-03-26netlink: Add support for NFC_CMD_ACTIVATE_TARGETChristophe Ricard5-0/+47
When reading a tag, it might be useful to have the ability to reactive it when it is in halt state. This will be usefull for example with specific tag type2.
2015-03-26gdbus: Make GDBusClient work without ObjectManagerLuiz Augusto von Dentz1-2/+7
This makes GDBusClient work normally without ObjectManager.