Skip to content

libatalk: map logtype identifiers correctly with the enum#2898

Merged
andylemin merged 2 commits intomainfrom
rdmark-logging-enum
Apr 18, 2026
Merged

libatalk: map logtype identifiers correctly with the enum#2898
andylemin merged 2 commits intomainfrom
rdmark-logging-enum

Conversation

@rdmark
Copy link
Copy Markdown
Member

@rdmark rdmark commented Apr 18, 2026

ATalkDaemon and PAPDaemon were present in the enum but absent from the string identifier array, shifting every entry from UAMS onward by -2. As a result, f.e. "spotlight:debug" in afp.conf resolved to logtype_fce (index 8) rather than logtype_sl (index 10), so Spotlight debug logging could never be enabled via the config file.

Add the two missing entries to restore correct alignment, while correcting man page documentation; this has
probably been broken ever since we grafted AppleTalk onto v4.0.

Also: fix OOB access when "end_of_list_marker" is passed as logtype

The bound check in setuplog_internal() compared typenum against num_logtype_strings, which includes the sentinel "end_of_list_marker" entry. This allowed typenum == logtype_end_of_list_marker (11) to pass the guard and index type_configs[] out of bounds (sized for indices 0-10).

Fix by comparing against logtype_end_of_list_marker directly, which is the actual size of type_configs[].

@augmentcode
Copy link
Copy Markdown

augmentcode Bot commented Apr 18, 2026

🤖 Augment PR Summary

Summary: Fixes a long-standing off-by-two mismatch between the enum logtypes values and their string identifiers.
Changes: Adds the missing ATalkDaemon/PAPDaemon entries so afp.conf logtype strings (e.g., Spotlight) map to the correct log targets, and updates the manpage accordingly.

🤖 Was this summary useful? React with 👍 or 👎

Copy link
Copy Markdown

@augmentcode augmentcode Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. 2 suggestions posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

Comment thread doc/manpages/man5/afp.conf.5.md Outdated
Comment thread libatalk/util/logger.c
rdmark added 2 commits April 18, 2026 23:50
ATalkDaemon and PAPDaemon were present in the enum but absent from the
string identifier array, shifting every entry from UAMS onward by -2.
As a result, f.e. "spotlight:debug" in afp.conf resolved to logtype_fce
(index 8) rather than logtype_sl (index 10), so Spotlight debug logging
could never be enabled via the config file.

Add the two missing entries to restore correct alignment,
while correcting man page documentation; this has
probably been broken ever since we grafted AppleTalk onto v4.0.
The bound check in setuplog_internal() compared typenum against
num_logtype_strings, which includes the sentinel "end_of_list_marker"
entry. This allowed typenum == logtype_end_of_list_marker (11) to pass
the guard and index type_configs[] out of bounds (sized for indices 0-10).

Fix by comparing against logtype_end_of_list_marker directly, which is
the actual size of type_configs[].
@rdmark rdmark force-pushed the rdmark-logging-enum branch from 5ea87cb to a5c6c4d Compare April 18, 2026 21:52
@rdmark rdmark requested a review from andylemin April 18, 2026 21:54
@sonarqubecloud
Copy link
Copy Markdown

@github-actions
Copy link
Copy Markdown
Contributor

🔥 Spectest (AFP 3.4) - Flamegraph (AFP_ASSERT active)

Commit: a5c6c4db6cafbd5b6c2685d15d2f2c0c5f4cf250
Profiling: On-CPU sampling @ 1009 Hz (prime), DWARF call-graph, x86_64
Build: debugoptimized (-O2 -g -fno-omit-frame-pointer)
Total Runtime: 66s, Netatalk Code-time: 4.4%,
Stacks: 1943, SVG size: 1.2M

🔥 Open interactive Flamegraph (SVG)

Flamegraph preview

📥 Download from artifacts →

🔝 Top 10 leaf functions
Function Samples
finish_task_switch.isra.0 582755040
do_syscall_64 430128720
_raw_spin_unlock_irqrestore 272547000
__cp_end 163528200
srso_alias_safe_ret 82259640
__syscall_cp_c 63429120
x64_sys_call 51536160
dircache_process_deferred_chain 35678880
kmem_cache_alloc_noprof 28741320
__pi_memset 26759160

Copy link
Copy Markdown
Contributor

@andylemin andylemin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well spotted!

@andylemin andylemin merged commit 57e6f08 into main Apr 18, 2026
55 checks passed
@rdmark rdmark deleted the rdmark-logging-enum branch April 18, 2026 23:10
@rdmark
Copy link
Copy Markdown
Member Author

rdmark commented Apr 18, 2026

I noticed it when desperately trying and failing to enable spotlight debug logging 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants