Fixes recommended by maintainer.
1. Buffer Overflow in FUSE Options Parsing (pfs.c)
- Fixed
2. Base64 Padding Bug (putil.c)
- I believe the padding logic at lines 273-284 is not a bug - it's correct per RFC 4648 base64 specification. Padding is only added when length != 0
(i.e., when there's a partial final block), and the correct number of "=" characters are added based on whether 1 or 2 bytes remain.
3. Memory Leaks in pdiff.c
- Fixed
4. Race Condition in Log Rotation (pdbg.c)
- I believe the code is actually already correct.
- The code at line 20 already uses volatile sig_atomic_t:
static volatile sig_atomic_t log_reopen_requested = 0;
This is the correct and safe pattern for signal handler communication:
1. sig_atomic_t - Guarantees atomic read/write operations (no partial updates)
2. volatile - Prevents the compiler from optimizing away accesses
The pattern is correct:
- Signal handler (pdbg_reopen_log at line 178-180) only sets the flag - async-signal-safe
- Main code checks/resets the flag inside pthread_mutex_lock() (lines 133-136, 231-234)
- Actual log reopening (do_reopen_log) happens in the main thread, not signal context
This is a well-established and safe pattern. The mutex ensures the check-and-reset is serialized with other logging, and sig_atomic_t
ensures the signal-to-main-thread communication is atomic.
5. Hardcoded RSA Padding (pssl.c)
- Fixed
6. Unchecked Exception (pclsync_lib.cpp)
- Fixed
7. Missing Input Validation
- Fixed
Issue #1: Double Logging and Memory Leak in `process_deletefile()`
- Fixed duplicate log.
- Note: There was no actual memory leak - the first path allocation at line 1731 was properly freed at line 1735 before the second
allocation at line 1739.
Issue #2: FUSE Options Parsing Problems
- Fixed
* another stupid macro gone
* more stupid macros gone. moved util functions from plibs to putil
* remaining plist and ptask functions moved to appropriate namespaces
* dead code beleted!
* bugfixes
* move sql functions to psql.c
* move sort functions into ppagecache
* psql namespace
* change plibs.h include to pdbg.h
* cleanup includes
- DoD 5220.22-M compliant memory wipe replaces single-pass zero wipe
- Wipe in-memory request and response messages before freeing
- Wipe in-memory private keys and salt data before freeing
- Wipe all passwords on unlink / logout
- Wipe crypto password on all pcryptofolder_unlock return paths
* support non-interactive command processing
- app is now configured in setup_app function
- added process_command() to api
- support piped input and -c argument
- fix memleaks
* add readline to dev containers
* pssl function names
* fix deprecated function warnings
* fix more deprecated function warnings
* fix warnings on write()
* pcommands.h for command ids
* remove compiler compat junk
* transient and unnecessary includes resolved
* unnecessary goto
* function naming and whatnot
* use readline for better command line UX
* add readline to CI workflow
* Revert "migrate mbedtls to 3.x (#89)"
This reverts commit f87367211d.
* prevent multiple execution of psync_fs_do_sotp and use atexit in sig hnd
* remove debug.[ch] in favor of plibs debug
* eliminate pcompat
* Decompose namespaces and other cleanup
* add missing unistd.h to psys.c (#113)
* remove useless comment
* code cleanup and removal
- remove useless wrapper functions
- remove obfuscating typedefs
- code reorganization and reformatting
- function renames for clarification
* prepare pcompat.h for decomposition
* remove dead function psync_rebuild_icons, reorganize pfsstatic.c headers
* separate pdevice from pcompat
* reorg function prototypes, remove more compat stuff
* renamed mutex for brevity
* remove dead debug code; plibs version is more sophisticated
* remove dead code, stale comments
* moved psync_delete_cached_crypto_keys to psynclib
* forgot to remove the function prototype from pdiff.h
* reorganized functions by accessibility, inlined useless psync_cache_contacts function
* remove unused header
* ppath object decomposed from pcompat
* ppath namespace
* ppath struct renames
* ppath final cleanup
* refactor, remove compatibility code
* format
* prun decomposed from pcompat for thread mgmt
* slim down prun.c
* remove useless comments
* move pagesize to pmemlock, pmemlock namespace
* pmem decomposed from pcompat, pmem namespace
* decompose psys from pcompat
* fix psys function names, remove more compatibility junk
* prand decomposed from pcompat
* psock decomposed from pcompat
* types renamed for ns consistency, brevity
* cleanup psock, remove unused proxy code
* remove unused headers psock
* putil for utility macros and functions
* forgot to move some psock constants
* move time macro to psys
* eliminate pcompat completely; new pfile namespace
* cleanup
- moved thread name definition
- explicit externs in implementation instead of headers for now
- better extern name
* migrate mbedtls to 3.x
* update github c-cpp workflow to use trixie
* update README and container-build
- default image and tag for container-build is now debian:trixie
- README for debian bookworm users
* final readme tweaks
* second attempt to update ci build workflow
* third attempt on ci build workflow
* fix deprecated calls in pssl.c
* small lsp error fixes
* simplify messaging and remove serialize/deserialize
- messaging is reverted to API requests and responses only
- remove serialize and deserialize functions
- implement shared memory (pshm) for overlay callback return values
* fix memory leak
Fix#64 and #71