Skip to content

Issue 6057 - Fix3 - Fix covscan issues #6127

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 25, 2024
Merged

Conversation

progier389
Copy link
Contributor

@progier389 progier389 commented Mar 18, 2024

Fix two minor issues reported by covscan after the previews fix:

  • CID 1540758: Null pointer dereferences - NULL_RETURNS
    /ldap/servers/slapd/back-ldbm/vlv.c: 412 in vlv_list_filenames
    Generate Null pointer exception if vlv config entry is not compliant to the schema
    Added a ternary test to harden the code.
  • CID 1540757: Null pointer dereferences - FORWARD_NULL
    /ldap/servers/slapd/back-ldbm/db-mdb/mdb_instance.c: 377 in dbmdb_open_all_files
    covscan complain that be may be null (which is true but not in the case database context is also NULL)
    Added a test to avoid the warning

Issue #6057

Reviewed by: @tbordaz, @droideck Thanks!

@progier389 progier389 self-assigned this Mar 18, 2024
Copy link
Contributor

@tbordaz tbordaz left a comment

Choose a reason for hiding this comment

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

LGTM

*/
slapi_log_err(SLAPI_LOG_ERR, "dbmdb_open_all_files",
"Unable to open the database environment witout either the database context or a backend.\n");
return DBI_RC_INVALID;
Copy link
Contributor

Choose a reason for hiding this comment

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

Or you may use the famous dbmdb_map_error(_FUNCTION, DBI_RC_INVALID) to log the backtrace

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed, but IMHO the backtrace is useless and I prefer avoiding using a sledgehammer to break a nut! 😉
The only case to trigger the failure is either that memory get corrupted or that we added new broken code
(So far the only case dbmdb_open_all_files is called with a NULL backend is at startup when setting up the database environment context and in that case the context that was just created is provided.
In the other case (typically when a backend is (re)started the backend is provided)

Copy link
Member

@droideck droideck left a comment

Choose a reason for hiding this comment

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

Commit subject looks a bit strange - "Issue i6057 - Fix3 - Fix covscan issues".
Besides that, LGTM!

@progier389 progier389 changed the title Issue i6057 - Fix3 - Fix covscan issues Issue 6057 - Fix3 - Fix covscan issues Mar 19, 2024
@progier389
Copy link
Contributor Author

Commit subject looks a bit strange - "Issue i6057 - Fix3 - Fix covscan issues". Besides that, LGTM!

I fixed the typo in the issue number but other wise it seems ok as it is the third PR about 6057 issue
(as the covscan warning get triggered by the second one)
And the bad news is that there may be a fourth one (because freeipa test is still failing. 😞 )

@progier389 progier389 merged commit 23a094c into 389ds:main Mar 25, 2024
jchapma pushed a commit that referenced this pull request Apr 10, 2024
Fix two minor issues reported by covscan after the previews fix:

CID 1540758: Null pointer dereferences - NULL_RETURNS
/ldap/servers/slapd/back-ldbm/vlv.c: 412 in vlv_list_filenames
Generate Null pointer exception if vlv config entry is not compliant to the schema
Added a ternary test to harden the code.
CID 1540757: Null pointer dereferences - FORWARD_NULL
/ldap/servers/slapd/back-ldbm/db-mdb/mdb_instance.c: 377 in dbmdb_open_all_files
covscan complain that be may be null (which is true but not in the case database context is also NULL)
Added a test to avoid the warning
Issue #6057

Reviewed by: @tbordaz, @droideck Thanks!
progier389 added a commit that referenced this pull request May 30, 2024
Fix two minor issues reported by covscan after the previews fix:

CID 1540758: Null pointer dereferences - NULL_RETURNS
/ldap/servers/slapd/back-ldbm/vlv.c: 412 in vlv_list_filenames
Generate Null pointer exception if vlv config entry is not compliant to the schema
Added a ternary test to harden the code.
CID 1540757: Null pointer dereferences - FORWARD_NULL
/ldap/servers/slapd/back-ldbm/db-mdb/mdb_instance.c: 377 in dbmdb_open_all_files
covscan complain that be may be null (which is true but not in the case database context is also NULL)
Added a test to avoid the warning
Issue #6057

Reviewed by: @tbordaz, @droideck Thanks!

(cherry picked from commit 23a094c)
@progier389 progier389 deleted the i6057_fix3 branch May 20, 2025 13:04
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.

3 participants