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

pmcx buffer overflow error if bc parameter has 12 characters #191

Closed
lkeegan opened this issue Oct 2, 2023 · 1 comment · Fixed by #192
Closed

pmcx buffer overflow error if bc parameter has 12 characters #191

lkeegan opened this issue Oct 2, 2023 · 1 comment · Fixed by #192

Comments

@lkeegan
Copy link
Contributor

lkeegan commented Oct 2, 2023

Setting 'bc': '______000010' gives:

*** buffer overflow detected ***: terminated

If I remove the last character, 'bc': '______00001', then it runs without errors.

lkeegan added a commit to lkeegan/mcx that referenced this issue Oct 2, 2023
- mcx_config.bc has type char[12], with no null terminator required
- resolves fangq#191
@fangq fangq closed this as completed in #192 Oct 3, 2023
@fangq
Copy link
Owner

fangq commented Oct 3, 2023

after checking the code, I found the issue you mentioned here also presents in mcxlab (and mcxcl). Because in mcxlab, I have been using cfg->bc as a NULL-terminating string for printing while in nearly all other places, I only read the first 12 bytes for bc flags.

To avoid issues of mixing use as a string as well as a byte array, I decided to expand the bc[] array in cfg to 13 to allow the ending NULL, 68db492

following this change, I also adjusted mcxlab.cpp and pmcx.cpp to handle the size checking and copying accordingly, see my above tagged commit.

Let me know if you see any problem.

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 a pull request may close this issue.

2 participants