Skip to content
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

strncpy source sizeof #94

Closed
2 tasks
superolmo opened this issue Mar 20, 2023 · 2 comments · Fixed by #108
Closed
2 tasks

strncpy source sizeof #94

superolmo opened this issue Mar 20, 2023 · 2 comments · Fixed by #108
Assignees
Milestone

Comments

@superolmo
Copy link

superolmo commented Mar 20, 2023

Checklist (Please check before submitting)

  • I reviewed the Contributing Guide.
  • I performed a cursory search to see if the bug report is relevant, not redundant, nor in conflict with other tickets.

Describe the bug
While building with -Werror=sizeof-pointer-memaccess flag the compiler complains about "error: argument to ‘sizeof’ in ‘strncpy’ call is the same expression as the source; did you mean to use the size of the destination?"

To Reproduce
Steps to reproduce the behavior:

  1. Add -Werror=sizeof-pointer-memaccess flag to compiler
  2. Build

Expected behavior
No errors

Code snips

strncpy(FileStatus->FileName, PathName, sizeof(PathName));

System observed on:

  • OS: Oracle Linux 8.7

Additional context
N/A

Reporter Info
Claudio Olmi - NASA/METECS

@jphickey
Copy link
Contributor

Yep, this is wrong. Thanks for pointing it out.

@jphickey jphickey added the bug label Mar 20, 2023
@pepepr08
Copy link
Contributor

pepepr08 commented May 4, 2023

I also had this error on my project. I'll submit the fix

@pepepr08 pepepr08 self-assigned this May 4, 2023
pepepr08 pushed a commit to pepepr08/DS that referenced this issue May 4, 2023
pepepr08 added a commit to pepepr08/DS that referenced this issue May 4, 2023
pepepr08 added a commit to pepepr08/DS that referenced this issue May 4, 2023
dzbaker added a commit that referenced this issue May 4, 2023
Fix #94, Use sizeof destination instead of source
@dmknutsen dmknutsen added this to the Equuleus milestone May 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants