Skip to content

Reject NULL contexts in liblsof API (#378) - #381

Open
hugojosealmeida wants to merge 2 commits into
lsof-org:masterfrom
hugojosealmeida:sdlc/issue-378-reject-null-contexts
Open

hugojosealmeida wants to merge 2 commits into
lsof-org:masterfrom
hugojosealmeida:sdlc/issue-378-reject-null-contexts

Conversation

@hugojosealmeida

Copy link
Copy Markdown
Contributor

Summary

Reject NULL contexts before dereferencing them in liblsof API entry points.

Changes

  • Guard gather, freeze, PID, and PGID entry points.
  • Add NULL-argument regression tests to make check.
  • Correct the documented error constant.

Verification

  • make check TESTS=tests/LTnull: pass.
  • Regression test and lib/lsof.c instrumented with ASan + UBSan: pass.

This PR is AI Assisted.

Closes #378

Comment thread include/lsof.h
* If the context is not frozen, lsof_freeze() will be called.
*
* \return LSOF_INVALID_ARGUMENT if either pointer argument is NULL
* \return LSOF_ERROR_INVALID_ARGUMENT if either pointer argument is NULL

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Add this annotation to other functions?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

LSOF_INVALID_ARGUMENT is not used by any function and is not defined. It was only a typo in this one documentation comment.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I mean, other functions could have \return annotations like this as well.

@hugojosealmeida
hugojosealmeida force-pushed the sdlc/issue-378-reject-null-contexts branch from e13301a to d47d9d4 Compare November 3, 2026 07:29
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.

Reject NULL contexts before dereferencing liblsof API arguments

2 participants