Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

properly initialized and checked Ethernet init callback (fix #890)#897

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed

Conversation

@maidnl
Copy link
Contributor

fix for potential null pointer access / _initializerCallback not initialized#890
This PR properly initializes _initializerCallback function pointer and checks for its validity before to call it

if (eth_if ==nullptr) {
//Q: What is the callback for?
_initializerCallback();
//A: To call a specific function on your system before any initialization is performed
Copy link
Contributor

Choose a reason for hiding this comment

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

❤️

@manchoz
Copy link
Contributor

@pennam
Copy link
Contributor

@maidnl@pennam see alsomain...manchoz:ArduinoCore-mbed:rm_initCallback

@manchoz are you aware of this callback being used somewhere?

@maidnl
Copy link
ContributorAuthor

Thanks@manchoz, however your PR removes completely the callback and this would brake backward compatibility (in case someone used the callback), so I would prefer to keep the callback and just make it safe.
What do you think@pennam ?

@manchoz
Copy link
Contributor

@pennam@maidnl, there is no code referring to this callback. AFAIK, it is a leftover of the early stages of the ArduinoCore-mbed.@facchinm WDYT?

@pennam
Copy link
Contributor

isn't already impossible to use the_initializerCallback() ?eth_if would never be anullptr because is always initialized here:

EthernetInterface *eth_if = &net;

@maidnl
Copy link
ContributorAuthor

@pennam, I could be wrong, but here is my understanding:
you have 3 constructors of EthernetClass (1)EthernetClass(EthernetInterface *_if), (2)EthernetClass();, (3)EthernetClass(voidPrtFuncPtr _cb)._initializerCallback() (which is pointer to function) is initialized using constructor (3) and is not related to eth_if. I agree however on the fact that eth_if could not be nullptr ever, but just because you cannot call the constructor EthernetClass(nullptr) because of the conflict between (1) and (3).
This PR is needed in all cases since _initializeCallback is not properly initialized nor there is a check for its validity when is called.

@pennam
Copy link
Contributor

@maidnl i was thinking if it makes any sense to keep the_initializerCallback() in the code:

  • using ctor 3EthernetClass(voidPrtFuncPtr _cb); the_initializerCallback() is never called becauseeth_if is always different fromnullptr
  • using ctor 2EthernetClass(); same story
  • using ctor 1EthernetClass(EthernetInterface *_if) you can teoretically create an Ethernet object with a nulleth_if, but you can't configure the_initializerCallback() 😞
JAndrassy reacted with thumbs up emoji

@manchoz
Copy link
Contributor

Let's go ahead and remove it. I don't see any use case for this feature.

@pennam
Copy link
Contributor

👍 let's go for#900

@pennam
Copy link
Contributor

superseded by#901

@pennampennam closed thisJun 20, 2024
@maidnlmaidnl deleted the fix_initializer_callback branchJuly 3, 2024 08:36
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@pennampennampennam left review comments

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@maidnl@manchoz@pennam

[8]ページ先頭

©2009-2025 Movatter.jp