Age | Commit message (Collapse) | Author | Files | Lines |
|
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
|
|
Add the Uid property to the tag-api documentation.
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
|
|
Compilation process was failing due 'const' qualifier ignored,
triggered by the ignored-qualifier flag.
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
|
|
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>
|
|
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>
|
|
Add i386 and GCC sanitizer builds on Debian Bullseye.
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
|
|
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>
|
|
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>
|
|
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>
|
|
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
|
|
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>
|
|
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>
|
|
While touching the copyrights, update my email address.
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
|
|
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
|
|
Add new systems for CI.
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
|
|
Drop old, unsupported Ubuntu Hirsute and Impish from CI matrix.
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
|
|
Add building under CI on Ubuntu Jammy Jellyfish (22.04).
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
|
|
Use include/uapi/linux/nfc.h from Linux kernel v5.17-rc4.
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
|
|
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>
|
|
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>
|
|
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
|
|
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
|
|
Build also Debian Testing on i386 and cross compile configurations.
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
|
|
Add older releases of Debian: Buster and Stretch.
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
|
|
Build on newest Ubuntu 21.10.
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
|
|
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>
|
|
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>
|
|
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
|
|
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
|
|
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
|
|
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>
|
|
Build in ArchLinux latest container.
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
|
|
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>
|
|
dnf is the new package manager on Fedora.
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
|
|
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>
|
|
Effect of autoupdate, without changing the version.
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
|
|
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
Helps debugging of container-specific configure failures.
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
|
|
Add Github CodeQL static analysis workflow.
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
|
|
Check the results if sanitizers were correctly linked.
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
|
|
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>
|
|
The installation scripts were based on LTP project.
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
|
|
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
|
|
Check also silent builds.
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
|
|
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
|
|
Makes cross compiling in CI easier.
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
|
|
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
|
|
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
The unit/test-ndef-parse.c duplicated several definitions which is
error-prone.
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
Cleanup and free memory in error paths in test-snep-read.c.
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
|
|
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>
|
|
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()
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
It's more readable.
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
Use near_ndef_msg_free() instead of open-coding it.
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
|
|
Use near_ndef_msg_free() instead of open-coding it.
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
No functional change.
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
Don't hard-code 0x80 because there is a define for it. No functional
change.
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
|
|
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>
|
|
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>
|
|
Let's polish this UTF-8. :)
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
There are no news.
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
|
|
Add the 'deactivate' option to test-tag which deactivates the
specified tag.
Signed-off-by: Mark Greer <mgreer@animalcreek.com>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
Remove the superfluous parentheses around calls to
t5_manufacturer_stmicro().
Signed-off-by: Mark Greer <mgreer@animalcreek.com>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
__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>
|
|
__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>
|
|
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>
|
|
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>
|
|
Ensure that the text encodings in WKT Text records are valid.
Signed-off-by: Mark Greer <mgreer@animalcreek.com>
|
|
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>
|
|
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>
|
|
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>
|
|
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
|
|
|
|
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) :
^~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
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>
|
|
|
|
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.
|
|
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.
|
|
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.
|
|
This is a preparation to support parsing of multiple records
inside one D-Bus message.
|
|
|
|
|
|
|
|
|
|
The secure element path is incorrect
|
|
The secure element path is incorrect
|
|
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.
|
|
org.neard and org.neard.Record have their own variable SERVICE_NAME
and RECORD_INTERFACE.
|
|
According to GP specification, an eSE should be accessible
when the ARA-M is not accessible.
|
|
|
|
|
|
|
|
|
|
nciattach includes near.h so we need to use the right include
path.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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.
|
|
|
|
This tool is needed to configure NCI UART drivers.
|
|
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.'
|
|
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.
|
|
There is no need to duplicate code in g_dbus_send_error_valist.
|
|
The g_dbus_get_flags function enables detection of when the
G_DBUS_FLAG_ENABLE_EXPERIMENTAL is set.
|
|
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."
|
|
When a select AID response status word is not 0x9000, the logical
channel used to communicate with this application should be closed.
|
|
Adding test-channel test script to manipulate channels on a
specific secure element.
|
|
Adding test-seel test script to manipulate secure element.
|
|
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.
|
|
A secure element may exist without any io_driver or without any
transceive function.
|
|
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.
|
|
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
|
|
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.
|
|
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.
|
|
This makes GDBusClient work normally without ObjectManager.
|