From 2c37de0ead1f5b06991f3da5432e9a2ba4adeba7 Mon Sep 17 00:00:00 2001 From: Pam Harris Date: Tue, 16 Apr 2024 09:58:06 -0600 Subject: [PATCH 1/2] Check for stoi out_of_range then convert header value to long --- src/ImageData/CompressedFits.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/ImageData/CompressedFits.cc b/src/ImageData/CompressedFits.cc index 49ffa2e33..7e9c9dda5 100644 --- a/src/ImageData/CompressedFits.cc +++ b/src/ImageData/CompressedFits.cc @@ -414,6 +414,10 @@ void CompressedFits::AddHeaderEntry( } catch (std::invalid_argument) { // Set string value only entry->set_entry_type(CARTA::EntryType::STRING); + } catch (std::out_of_range) { + long lvalue = std::stol(value); + entry->set_numeric_value(lvalue); + entry->set_entry_type(CARTA::EntryType::INT); } } } From ad6564cf883dfba2593eaf37e101cc50702edbef Mon Sep 17 00:00:00 2001 From: Pam Harris Date: Tue, 16 Apr 2024 10:02:50 -0600 Subject: [PATCH 2/2] Update changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 31cc83ffb..609e83f81 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed +* Fix crash when parsing FITS header long value ([#1366](https://github.com/CARTAvis/carta-backend/issues/1366)). + ### Changed * Move the loader cache to separate files ([#1021](https://github.com/CARTAvis/carta-backend/issues/1021)). * Improve the code style in HTTP server ([#1260](https://github.com/CARTAvis/carta-backend/issues/1260)).