Commit Graph
2539 Commits
Author SHA1 Message Date
peri4 f55bc51d18 try to obtain buttons/axes names of HID 2026-09-05 11:14:58 +03:00
peri4 b1af66bee7 Merge pull request 'Support building with musl libc (Alpine Linux)' (#216) from alpine-musl-build into master
Reviewed-on: #216
2026-08-30 20:11:58 +03:00
andrey 446eea404f support building with musl libc (Alpine Linux)
- use LFS64 file/stat APIs only on glibc/Windows (absent in musl)
- use plain sched_priority outside glibc
- do not declare pow10(double) where the system provides C23 pow10() (musl)
- ICU is off by default: modern ICU (>= 75) needs C++17 for its headers,
  the project is built with C++11; enable explicitly with -DICU=ON
- fix latent crash: PIThread::setThreadName() read the thread handle from
  inside the new thread; the handle is not guaranteed to be visible before
  start (musl publishes it later), rename the calling thread via
  pthread_self() instead
2026-08-29 22:04:46 +00:00
andrey 47f9119afe Merge pull request 'Add GDB pretty-printers for basic types (PIString, PIVector, PIMap, PIByteArray, etc.)' (#213) from gdb_pretty_printers into master
Reviewed-on: #213
2026-08-27 20:11:00 +03:00
andrey 6418a835e7 update doc 2026-08-27 20:08:59 +03:00
andrey 49c95dbe72 add Qt Creator dumper for PIP types and PINetworkAddress GDB printer 2026-08-27 18:03:25 +03:00
peri4 2764df8591 adopt for host Windows 2026-08-27 13:34:31 +03:00
peri4 cce1f6fa5c Merge pull request 'add PIIODevice::shutdown()' (#215) from master into gdb_pretty_printers
Reviewed-on: #215
2026-08-27 03:40:12 +03:00
peri4 59c7e99e50 add PIIODevice::shutdown() 2026-08-26 11:38:30 +03:00
andrey ef1fa8077a Add GDB pretty-printers for basic types (PIString, PIVector, PIMap, PIByteArray, etc.)
Python pretty-printer script (tools/gdb/pip_pp.py) for the GDB debugger:
- PIString (UTF-16, escapes, surrogate pairs), PIByteArray (hex), PIChar
- PIVector<T>, PIDeque<T>, PIStringList, PIMap<K,V>, PISet<T>, PIPair<K,V>
- PIVariant (type + serialized size)
- pointers: (PIString *) 0x... "hello"; long containers truncated
- manual: gdb source tools/gdb/pip_pp.py
- automatic: CMake install ships share/pip/gdb/pip_pp.py and the
  libpip.so-gdb.py auto-load stub next to the library (shared builds)
- verification: tools/gdb/test/test_pp.sh <build-dir>
- docs: doc/pages/debugging.md
2026-08-23 20:24:34 +03:00
peri4 b1cab18496 version 5.9.0 2026-08-17 20:36:43 +03:00
peri4 b1060fd572 PIEthernet fix: no more close outdated fd on disconnect (error at work with MHD) 2026-08-17 20:26:36 +03:00
andrey aed98059de Merge pull request 'add rpm support for deploy_tool' (#211) from rpm_support into master
Reviewed-on: #211
2026-08-12 17:05:48 +03:00
andrey 9214e805d9 add rpm support for deploy_tool 2026-08-11 19:04:33 +03:00
andrey 5fe03eaf96 fix ctest 2026-08-11 14:41:25 +03:00
andrey a81a450c44 Merge pull request 'Bugfixes part 3' (#209) from bugfixes3 into master
Reviewed-on: #209
2026-08-11 11:16:55 +03:00
andrey f2d692725a version 2026-08-11 11:15:57 +03:00
andrey c8f6fe7641 Reapply "fix: PISingleApplication TOCTOU — two shm reads replaced with single atomic read"
This reverts commit fc2e49b096.
2026-08-10 21:39:31 +03:00
andrey ace5960e70 fix(piusb): fix 4 bugs in USB read/write/enumeration/close
1. Missing break in readDevice() Bulk case: Bulk read result was
   overwritten by interrupt read, silently corrupting all bulk reads.

2. Wrong variable in writeDevice(): switch checked ep_read instead
   of ep_write; Interrupt case used ep_read.address for writes.

3. Interface mismatch in closeDevice(): always released interface 0
   (intefrace_) instead of the actually claimed interface
   (interface_claimed), leaking non-zero interface claims.

4. Wrong index in interface enumeration: used outer loop variable c
   (configuration index) instead of i (interface index), reading
   wrong interface descriptors or causing OOB access.
2026-08-10 16:26:30 +03:00
andrey 69673ff7c6 fix(curl_thread_pool): clean up clients_in_proc in destroy()
destroy() aborted and deleted clients in the queue but did not
delete clients that were currently being processed (clients_in_proc).
If a thread was terminated while processing a client, that client
object and its CURL handle were leaked.
2026-08-10 16:26:23 +03:00
andrey 9a4384a378 fix(piopencl): release context on command queue creation failure
If clCreateContext succeeded but clCreateCommandQueue failed,
the context handle was returned without being released, leaking
the OpenCL context and all associated GPU resources.
2026-08-10 16:26:18 +03:00
andrey 4d2c268710 fix(piluaprogram): add destructor to close Lua state
luaL_newstate() allocates a Lua state (~2-4 MB with libraries)
in the constructor, but there was no destructor to call lua_close().
Every PILuaProgram instance leaked its entire Lua state.
Add ~PILuaProgram() that calls lua_close(PRIVATE->lua_state).
2026-08-10 16:26:13 +03:00
andrey 9294cd7b7b fix(picrypt): use crypto_box_* constants for public-key decrypt
The decrypt() function for crypto_box (public-key) used
crypto_secretbox_NONCEBYTES and crypto_secretbox_MACBYTES
(secret-key constants) instead of crypto_box_* constants.
These happen to be equal in libsodium but are semantically
different APIs. Fix ensures consistency with the encrypt()
counterpart.
2026-08-10 16:26:08 +03:00
andrey 16adea05af fix(picompress): pass correct source size to uncompress()
piDecompress() appended original size as 8-byte ullong at the end
of compressed data, but passed zba.size() (including the 8 bytes)
to uncompress(). This fed trailing metadata as part of the zlib
stream. Fix: subtract sizeof(ullong) from source length.
2026-08-10 16:26:02 +03:00
andrey aa64eb4c7f fix(pibasetransfer): fix ABBA deadlock — enforce consistent mutex lock ordering
received() acquired mutex_header and mutex_session in different orders
depending on packet type:
  - pt_Data path:  mutex_header → mutex_session
  - pt_Start path: mutex_session → mutex_header

send_process() acquires mutex_session independently. When running
concurrently with received(), the reversed lock ordering creates a
classic ABBA deadlock scenario.

Fix: enforce consistent ordering (mutex_header → mutex_session) in
all code paths. Restructured pt_Start case and buildSession() to
always acquire mutex_header before mutex_session.
2026-08-10 15:48:40 +03:00
andrey c3bdc5464e fix(piconnection): prevent UAF in DevicePool::run() during connection deletion
The background run() thread copies allConnections() then iterates
each connection's diags_ map. If a PIConnection is deleted from
another thread between the copy and the iteration, dereferencing
the pointer is UAF. Add null check and protect diags_ iteration
with __device_pool__ lock.
2026-08-10 15:48:31 +03:00
andrey b180d91b1e fix(pibasetransfer): make shared flags std::atomic<bool> to eliminate data race
Flags break_, is_sending, is_receiving, is_pause are accessed from
both the send thread (send_process) and the read thread (received)
without synchronization. Plain bool reads/writes from multiple threads
is undefined behavior per C++ standard. Convert to std::atomic<bool>
with proper initializers.
2026-08-10 15:48:24 +03:00
andrey 1c9cdbba19 fix(picloudserver): use piMin<ssize_t> to avoid signed/unsigned UB in Client::readDevice
piMini(max_size, buff.size()) implicitly narrows size_t to int,
which is UB for large buffers. Replace with explicit piMin<ssize_t>
matching the correct pattern used in picloudclient.cpp.
2026-08-10 15:48:12 +03:00
andrey f9a846a3e9 Revert "fix(PIFFT_float): correct plan entry size from 4 to 8"
This reverts commit 2bb3884aee.
2026-08-10 14:59:18 +03:00
andrey fc2e49b096 Revert "fix: PISingleApplication TOCTOU — two shm reads replaced with single atomic read"
This reverts commit 1b23a258b8.
2026-08-10 14:59:13 +03:00
andrey 1a153eefbc fix(PISystemInfo): correct guard for df output parsing
The guard ml.size_s() < 2 allowed size==2, but ml[2] was then
accessed — OOB read on truncated or unusual df output lines.
2026-08-06 17:01:30 +03:00
andrey 9e280ef976 fix(PISerial): close fd when probe read fails in availableDevicesInfo
When the non-blocking probe read returned EIO, the loop continued
without closing the file descriptor, leaking one fd per rejected
port on each call.
2026-08-06 17:01:30 +03:00
andrey c8ad8ecaf4 fix(PISPI): close fd on ioctl error paths
Three ioctl calls after successful open() returned false without
closing the file descriptor, leaking one fd per failed open attempt.
2026-08-06 17:01:30 +03:00
andrey 1aa6f1af81 fix(PIByteArray): prevent OOB in fromBase64 with non-multiple-of-4 input
The buffer was sized as floor(sz/4)*3 but the loop ran ceil(sz/4)
times, writing 3 bytes per iteration. For sz%4!=0, this wrote past
the buffer end. Also guarded sz<4 to avoid processing trivially
short or malformed input.
2026-08-06 17:01:30 +03:00
andrey 5e4a55cc0c fix(PIThread): remove spurious unlock() in _waitForFinish
The function called unlock() on thread_mutex without a matching
lock(), causing UB on Windows (releasing an unowned critical
section) or silently dropping a user-held lock.
2026-08-06 17:01:30 +03:00
andrey 31ae52623d fix(PIConditionVariable): clamp negative timeout in waitFor
When elapsed time exceeded the timeout, the remaining milliseconds
expression went negative and was implicitly converted to DWORD,
wrapping to ~0xFFFFFFFF (5 days) — effectively INFINITE.
Now clamps to 0 and returns false when time has elapsed.
2026-08-06 17:01:30 +03:00
andrey 4d9cd20ac5 fix(PIDir): initialize list pointer and check scandir return
dirent** list was uninitialized, so scandir failure (returning -1)
left it with indeterminate value. The unconditional free(list) at
the end was then UB — typically heap corruption or crash.
2026-08-06 17:01:30 +03:00
andrey 3e72f4e533 fix(PIBitArray): guard pop_back() against empty array
pop_back() called resize(size_ - 1) without checking for empty.
On empty array, uint underflow produced UINT_MAX, causing
bytesInBits(UINT_MAX) overflow and subsequent OOB access.
pop_front() already had this guard; pop_back() was missing it.
2026-08-06 17:01:30 +03:00
andrey c3cd9496dd fix(PIVariant): add missing break in setValueFromString switch
Three complex type cases (pivComplexf, pivComplexd, pivComplexld)
lacked break statements, causing fallthrough to pivTime. Setting
a complex variant from string silently overwrote the value with
PITime::fromString(), corrupting the variant's type and data.
2026-08-06 17:01:30 +03:00
andrey ef8fdb30f4 fix(PISharedMemory): reset data and unlink on mmap failure
When mmap() returned MAP_FAILED, data stayed as (void*)-1, causing
subsequent read/write/close to pass the null guard and crash.
Now resets data=nullptr, and calls shm_unlink when owner=true to
avoid orphaned shared memory objects.
2026-08-06 17:01:30 +03:00
andrey 9c3690d371 fix(PIFFT_float): correct plan entry size from 4 to 8
The float FFT plan generator wrote 8 ints per entry (indices +0..+7)
but declared entrysize=4, causing heap overwrite into the next entry
and incorrect plan array sizing.
2026-08-06 17:01:30 +03:00
andrey 288c1b3575 fix: Sender::tick accesses parent->diags_ without lock — data race / use-after-free 2026-08-06 17:01:30 +03:00
andrey f5cf06c200 fix: addDevice deletes read thread without stopAndWait — race on dev close/open 2026-08-06 17:01:30 +03:00
andrey 4f601a9408 fix: removeAllFilters holds lock during delete — move destructors outside lock scope 2026-08-06 17:01:30 +03:00
andrey c3491cbf6f fix: PISingleApplication TOCTOU — two shm reads replaced with single atomic read 2026-08-06 17:01:30 +03:00
andrey 96f0221051 fix: PIStreamPacker division by zero when max_packet_size is 0 2026-08-06 17:01:30 +03:00
andrey 9680bb2af8 fix: remove unreachable return false in PICrypt::verifySign()
fix picrypth
2026-08-06 17:01:30 +03:00
andrey cb5530c864 fix: writePipe loses data on partial write > PIPE_BUF 2026-08-06 17:01:30 +03:00
andrey 736acbd419 fix: interfaceAddress buffer overflow on long interface names 2026-08-06 17:01:30 +03:00
andrey 27ed1bc9a7 fix: SIOCGIFMTU passes int* instead of ifreq* (Android) 2026-08-06 17:01:30 +03:00