Skip to content

fix(webserver): php_amule_lib various fixes - #152

Merged
got3nks merged 3 commits into
amule-org:masterfrom
RealGreenDragon:fix_php_amule_lib
Jun 14, 2026
Merged

fix(webserver): php_amule_lib various fixes#152
got3nks merged 3 commits into
amule-org:masterfrom
RealGreenDragon:fix_php_amule_lib

Conversation

@RealGreenDragon

Copy link
Copy Markdown

Fixes:

  • Null pointer dereference in php_get_amule_stats, php_get_amule_categories, and amule_load_stats_tree functions
  • Removed string check from php_native_search_download_cmd function (useless as the value is cast to int, so an int parameter value can be accepted, as happens in other functions such as php_native_server_cmd)

@got3nks got3nks left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thanks. All three fixes verified:

  • GetTagByNameGetTagByNameSafe for the four EC_TAG_STATS_* + EC_TAG_CATEGORY_TITLE call sites — correct null-deref guards.
  • amule_load_stats_tree null-check on stats_root + delete response — correct, also avoids the leak on the error path.
  • String-check removal — same pattern + rationale as #151.

Other unsafe GetTagByName(...)->method() chains exist in this file (lines 269, 278, 285, 293, 432) but those are separate concerns and fine to leave for a follow-up. This PR's scope is correctly tight.

Approving.

@got3nks
got3nks merged commit bff0a08 into amule-org:master Jun 14, 2026
10 checks passed
@RealGreenDragon
RealGreenDragon deleted the fix_php_amule_lib branch June 14, 2026 12:24
@RealGreenDragon

Copy link
Copy Markdown
Author

Other unsafe GetTagByName(...)->method() chains exist in this file (lines 269, 278, 285, 293, 432) but those are separate concerns and fine to leave for a follow-up. This PR's scope is correctly tight.

@got3nks I checked but no fix needed in lines 269, 278, 285, 293, 432. After each GetTagByName(...) there is a NULL check (via ternary in 432 and via if in other cases) so code now is safe and replacing withGetTagByNameSafe(...) will break existing checks (that check direct NULL and not an object with a NULL in a field).

Thank you very much for review !

@got3nks

got3nks commented Jun 14, 2026

Copy link
Copy Markdown

You're right — verified all five, every dereference is already gated by a NULL check (if (!tag) return; at 269, if ( server ) / if ( sname ) / if ( susers ) at 278 / 285 / 293, inline ternary at 432). And yes, swapping to GetTagByNameSafe would break those guards — it returns a non-NULL placeholder for missing tags, so the if (!x) branches would invert silently. Should have walked all five before flagging. Thanks for the double-check.

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