Skip to content
New issue

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

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix(userspace/libsinsp): properly use strlen instead of sizeof when assigning user/group string infos #1813

Merged
merged 2 commits into from
Apr 24, 2024

Conversation

FedeDP
Copy link
Contributor

@FedeDP FedeDP commented Apr 24, 2024

What type of PR is this?

/kind bug

Any specific area of the project related to this PR?

/area libsinsp

Does this PR require a change in the driver versions?

What this PR does / why we need it:

Small fixup on top of #1765.
cc @erthalion

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

NONE

…en assigning user/group string infos.

Signed-off-by: Federico Di Pierro <nierro92@gmail.com>

Co-authored-by: Andrea Terzolo <andreaterzolo3@gmail.com>
Co-authored-by: Jason Dellaluce <jasondellaluce@gmail.com>
Co-authored-by: Luca Guerra <luca@guerra.sh>
@FedeDP
Copy link
Contributor Author

FedeDP commented Apr 24, 2024

/milestone 0.16.0

@poiana poiana requested review from gnosek and hbrueckner April 24, 2024 10:44
@poiana poiana added this to the 0.16.0 milestone Apr 24, 2024
@poiana poiana added the size/S label Apr 24, 2024
Andreagit97
Andreagit97 previously approved these changes Apr 24, 2024
Copy link
Member

@Andreagit97 Andreagit97 left a comment

Choose a reason for hiding this comment

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

/approve

LucaGuerra
LucaGuerra previously approved these changes Apr 24, 2024
@erthalion
Copy link
Contributor

Thanks @FedeDP. From what I understand the data for those fields is coming from getpwent/fgetpwent. I can't find immediately if those functions always return null terminated strings, but probably worth using strnlen with MAX_CREDENTIALS_STR_LEN/SCAP_MAX_PATH_SIZE?

@FedeDP
Copy link
Contributor Author

FedeDP commented Apr 24, 2024

I can't find immediately if those functions always return null terminated strings

While i can't find it either, i assume it returns NULL terminated strings since it does not return any len for the char buffers.
Otherwise it would be a really bad API :)

But better safe than sorry, i agree.

Signed-off-by: Federico Di Pierro <nierro92@gmail.com>

Co-authored-by: Dmitrii Dolgov <9erthalion6@gmail.com>
@FedeDP FedeDP dismissed stale reviews from LucaGuerra and Andreagit97 via ddf0094 April 24, 2024 14:07
Copy link
Member

@Andreagit97 Andreagit97 left a comment

Choose a reason for hiding this comment

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

/approve

@poiana
Copy link
Contributor

poiana commented Apr 24, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Andreagit97, FedeDP, LucaGuerra

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [Andreagit97,FedeDP,LucaGuerra]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@poiana poiana merged commit e428555 into master Apr 24, 2024
39 of 40 checks passed
@poiana poiana deleted the fix/user_group_strings_strlen branch April 24, 2024 14:52
@FedeDP FedeDP mentioned this pull request Apr 29, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants