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

DM-47152: Writing FITS header with long keywords and long strings is broken #750

Merged
merged 1 commit into from
Oct 29, 2024

Conversation

PaulPrice
Copy link
Contributor

Ensures that long keywords have HIERARCH prepended.
Otherwise, cfitsio doesn't treat them right. In particular, long string values have the CONTINUE convention messed up, and I've seen it swallow chars from the string value to put in the HIERARCH.
Includes a test that fails without this fix.

@PaulPrice PaulPrice requested a review from TallJimbo October 26, 2024 21:03
src/fits.cc Outdated
if (keyName.size() > 8 && keyName.rfind("HIERARCH ", 0) != 0) {
keyName = "HIERARCH " + keyName;
}
char const* keyStr = keyName.c_str();
Copy link
Member

@TallJimbo TallJimbo Oct 28, 2024

Choose a reason for hiding this comment

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

It should be just as fast and a bit safer to just call c_str() whenever you use this variable below (instead of defining the variable, I mean); what you have now is safe, but it would only take a small perturbation for keyStr to get used after keyName goes out of scope.

Otherwise, cfitsio doesn't treat them right. In particular,
long string values have the CONTINUE convention messed up,
and I've seen it swallow 9 chars from the string value to
put in the HIERARCH.
@PaulPrice PaulPrice merged commit 33b1fcc into main Oct 29, 2024
2 checks passed
@PaulPrice PaulPrice deleted the tickets/DM-47152 branch October 29, 2024 14:12
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.

2 participants