Commit Graph

139 Commits

Author SHA1 Message Date
Levi Neely df102c98f3 Fix all psync_list_for_each_element_call to use pmem_free wrappers 2026-03-08 20:05:32 +01:00
Levi Neely bad3430968 Fix pfolder.c psync_free_string_list to use pmem_free() 2026-03-08 20:03:15 +01:00
Levi Neely 82226831df Add missing pmem.h include to pdevice.c 2026-03-08 19:57:31 +01:00
Levi Neely a0535bcadd Fix pnetlibs_debug.c free() call - migrate to pmem_free() 2026-03-08 19:56:00 +01:00
Levi Neely 7f24fabc54 Fix all remaining stray free() calls - migrate to pmem_free() 2026-03-08 19:55:21 +01:00
Levi Neely 9cb9cfccbd Migrate psettings.c free() calls to pmem_free() 2026-03-08 19:51:02 +01:00
Levi Neely 506de72ab0 Fix prand.c mixed allocation - use pmem_free for putil_strdup result 2026-03-08 19:49:16 +01:00
Levi Neely deb61a40f8 Fix pmem.c infinite recursion - use raw malloc/free internally 2026-03-08 19:30:22 +01:00
Levi Neely 86460c7568 Fix ptask.c callback arguments - remove PMEM_SUBSYS_OTHER from s->free calls 2026-03-08 19:22:20 +01:00
Levi Neely b839a9a6a9 Fix ptask.c compilation errors - replace s->pmem_free with s->free 2026-03-08 19:20:08 +01:00
Levi Neely 6efaac5370 Add pmem.h include to 10 files missing it 2026-03-08 19:17:52 +01:00
Levi Neely 709e6d7fe9 Add pmem.h include to pdbg.c 2026-03-08 19:15:48 +01:00
Levi Neely 4fb8078978 Fix pcache.c compilation errors - replace he->pmem_free with pmem_free 2026-03-08 19:13:42 +01:00
Levi Neely bc36713350 Migrate papi.c, ptools.c, pbusinessaccount.c to PMEM_SUBSYS_API 2026-03-08 19:11:04 +01:00
Levi Neely 7d10cf8d6c Migrate remaining 34 files to pmem_malloc/pmem_free 2026-03-08 19:08:22 +01:00
Levi Neely 70dbe0104c Fix panic() infinite recursion by unregistering handlers before abort() 2026-03-08 18:57:16 +01:00
Levi Neely bf1d1caf2f Add panic() with backtrace to psignal module 2026-03-08 18:25:57 +01:00
Levi Neely b0f071ef23 Fix multiplication pattern in psock.c with overflow checks 2026-03-08 18:06:47 +01:00
Levi Neely 9f8f25183e Migrate psock.c malloc/free to pmem_malloc/pmem_free 2026-03-08 18:03:03 +01:00
Levi Neely 3f17f6333d Migrate pupload.c malloc/free to pmem_malloc/pmem_free 2026-03-08 17:53:56 +01:00
Levi Neely 9113a17ca8 Migrate pcrypto.c malloc/free to pmem_malloc/pmem_free 2026-03-08 17:52:03 +01:00
Levi Neely 66faf0e7cd Migrate pdiff.c malloc/free to pmem_malloc/pmem_free 2026-03-08 17:45:10 +01:00
Levi Neely 95d02868af Migrate pfsupload.c malloc/free to pmem_malloc/pmem_free 2026-03-08 17:40:25 +01:00
Levi Neely 655e14a485 Fix multiplication patterns in putil.c encoding functions with overflow checks 2026-03-08 17:30:52 +01:00
Levi Neely b74f5f2049 Migrate putil.c malloc/free to pmem_malloc/pmem_free 2026-03-08 17:26:36 +01:00
Levi Neely 827722724a Migrate psql.c malloc/free to pmem_malloc/pmem_free 2026-03-08 17:21:37 +01:00
Levi Neely 7cebfd6e58 Migrate plocalscan.c malloc/free to pmem_malloc/pmem_free 2026-03-08 17:16:58 +01:00
Levi Neely 3b5e34cfd6 Migrate publiclinks.c malloc/free to pmem_malloc/pmem_free 2026-03-08 17:12:25 +01:00
Levi Neely 37497aace2 Fix multiplication patterns in pfolder.c with overflow checks 2026-03-08 17:08:22 +01:00
Levi Neely f2c1ee615f Migrate pfolder.c malloc/free to pmem_malloc/pmem_free 2026-03-08 17:04:39 +01:00
Levi Neely 115cbba660 Migrate pcryptofolder.c malloc/free to pmem_malloc/pmem_free 2026-03-08 17:00:52 +01:00
Levi Neely 0ca4b25821 Migrate pssl.c malloc/free to pmem_malloc/pmem_free 2026-03-08 16:38:41 +01:00
Levi Neely f578c80a50 Fix remaining multiplication pattern in ppagecache.c line 3239 2026-03-08 16:33:48 +01:00
Levi Neely e495309ae3 Migrate ppagecache.c malloc/free to pmem_malloc/pmem_free 2026-03-08 16:30:54 +01:00
Levi Neely 0fcee5cd75 Fix multiplication patterns in pnetlibs.c with pmem_malloc_array 2026-03-08 16:25:42 +01:00
Levi Neely 84c8d2a0ee Migrate pnetlibs.c malloc/free to pmem_malloc/pmem_free 2026-03-08 16:22:44 +01:00
Levi Neely fd19b075ae Migrate pfstasks.c malloc/free to pmem_malloc/pmem_free 2026-03-08 16:17:12 +01:00
Levi Neely 3f7f9d716c Add overflow-safe pmem_malloc_array function 2026-03-08 16:04:20 +01:00
Levi Neely 964a5fcde9 Migrate malloc/calloc to pmem_malloc with subsystem tracking 2026-03-08 15:55:33 +01:00
Levi Neely fc44baab8b Implement memory accounting infrastructure 2026-03-08 15:45:26 +01:00
Levi Neely 8276034f70
Add lock ordering assertions in debug builds (#370)
* Add lock ordering assertions for psql_lock → file mutex

* Add missing psql.h include to pfs.h

* Fix debug build conditional compilation for lock ordering assertions

* Fix function declaration order for pfs_debug_check_lock_order

---------

Co-authored-by: Levi Neely <lkn@darkstar.example.net>
2026-03-08 15:38:41 +01:00
Levi Neely d0c213f181
Add overflow-safe allocation wrapper pmem_calloc_safe() (#369)
* Add overflow-safe allocation wrappers to pmem module

* Replace malloc(nmemb*size) with pmem_calloc_safe in high-risk sites

---------

Co-authored-by: Levi Neely <lkn@darkstar.example.net>
2026-03-08 14:55:21 +01:00
Levi Neely 89ef8663b0
Add psignal module for centralized signal handling (#368)
* Add psignal module for centralized signal handling

- Added pclsync/psignal.h with psignal_register() and psignal_check_pending() API
- Added pclsync/psignal.c with async-signal-safe handlers for SIGINT, SIGTERM, SIGHUP
- Implements flag-based deferred signal handling pattern

* Integrate psignal into main loop and remove conflicting handlers

- Added extern "C" linkage to psignal.h for C++ compatibility
- Integrated psignal_check_pending() into pclsync_lib.cpp main loop
- Integrated psignal_check_pending() into ptimer.c timer loop
- Removed conflicting signal handlers from pfs.c

* Migrate psync_set_signal to psignal module

- Added psignal_set_custom_handler() to psignal.h and psignal.c
- Replaced psync_set_signal() calls in pfs.c with psignal_set_custom_handler()
- Centralizes all signal handling in psignal module

---------

Co-authored-by: Levi Neely <lkn@darkstar.example.net>
2026-03-08 14:27:21 +01:00
Levi Neely 5ad532b692
Add NULL check audit to high-risk allocations (#366)
Co-authored-by: Levi Neely <lkn@darkstar.example.net>
2026-03-08 13:11:41 +01:00
Levi Neely 645596ac15
Add deadlock detection with timeouts (#364)
Co-authored-by: Levi Neely <lkn@darkstar.example.net>
2026-03-08 11:55:25 +01:00
Levi Neely 5769bb4882
Fix pcl-10w: remove IS_DEBUG conditional from psql.h (#363)
Removed IS_DEBUG conditional block from psql.h. Added psql_dump_locks() declaration. Now uses single API without debug/release variants. This eliminates the last remaining use of IS_DEBUG after PR #177.

Fixes #178

Co-authored-by: Levi Neely <lkn@darkstar.example.net>
2026-03-07 21:37:21 +01:00
Levi Neely 6a0edf0cc3
Fix pcl-ivv: remove weak attribute from debug hooks (#362)
Removed weak attribute from debug hooks (psys_debug_abort_on_sqllock and psys_debug_configure_core_dump). Made functions static in psys.c and removed declarations from psys.h. Functions can no longer be overridden by external libraries, preventing potential code execution and security bypass.

Fixes #289

Co-authored-by: Levi Neely <lkn@darkstar.example.net>
2026-03-07 20:18:51 +01:00
Levi Neely 431f94725f
Fix pcl-r0j: rename psync_delete_sync_by_folderid to pfolder_delete_sync_by_id (#361)
Renamed psync_delete_sync_by_folderid to pfolder_delete_sync_by_id to align with pfolder API naming conventions. Updated all callers.

Fixes #100

Co-authored-by: Levi Neely <lkn@darkstar.example.net>
2026-03-07 19:54:21 +01:00
Levi Neely f17fb19b85
Fix log file permissions: use mode 0600 (#359)
Replace fopen() with open()+fdopen() for all log file creation
in pdbg.c to ensure files are created with mode 0600, preventing
world-readable logs that may contain sensitive information.

Fixes #290

Co-authored-by: Levi Neely <lkn@darkstar.example.net>
2026-03-07 19:20:51 +01:00
Levi Neely e37c7f5894
Fix pcl-dls: errPtr memory leak between ptools_backend_call() calls in ptools_set_backend_file_dates() (#358)
* Fix pcl-dls.1: free errPtr between calls in ptools_set_backend_file_dates()

char *errPtr was already used instead of char msgErr[1024], but was
not freed between the two ptools_backend_call() invocations. If the
first call allocated errPtr, the second would overwrite the pointer
without freeing it. Add free(errPtr); errPtr = NULL; between the two
calls to eliminate the leak.

Ref GH #194.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Add ptools_set_backend_file_dates() errPtr lifecycle tests (pcl-dls)

6 test cases using malloc/free wrapping covering both-succeed,
call1-error, call2-error, both-errors, pre-fix leak demonstration,
and no-double-free after mid-free NULLing.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Levi Neely <lkn@darkstar.example.net>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-07 19:01:17 +01:00