Pawn: report missing legacy plugin file instead of misreporting it as a component - #1275
Open
berkleblebiciii wants to merge 1 commit into
Conversation
… a component
`Spawn()` discarded `Canonicalise()`'s return value. On Linux
`Canonicalise()` uses `realpath()`, which fails for a missing file and
left the result empty, so `dlopen("")` ran. That resolves to the main
program's handle, and `dlsym("ComponentEntryPoint")` on it matched the
exported symbol, producing the misleading "This file is an open.mp
component" message. Check the return value and report that the plugin
file could not be found instead.
Fixes openmultiplayer#1272
Contributor
|
There's already this. Why making the same PRs for the already suggested solutions? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
If a legacy plugin listed in
pawn.legacy_pluginsdoes not exist inplugins/, the Linux server currently prints:which is misleading - the file is not an open.mp component, it simply does not exist. Windows correctly reports the missing file, so the two platforms behave differently.
Root cause
Spawn()discardedCanonicalise()'s return value and handed its output to the loader. On LinuxCanonicalise()usesrealpath(), which fails for a missing file and left the result empty, sodlopen("")ran - that resolves to the main program's handle, anddlsym("ComponentEntryPoint")on it matched the server's own exported$CAPIsymbol, producing the component message. Windows was unaffected becausePathCanonicalizeA()is purely lexical, soLoadLibraryAstill ran and reported the OS error.Fix
Check
Canonicalise()'s return value inPawnPluginManager::Spawn()and, when it fails, print a file-not-found message and return before constructing thePawnPlugin.After the fix, Linux prints:
Windows behaviour is unchanged:
Canonicalise()still succeeds lexically, so the OS loader error is reported as before.Fixes #1272