Conversation
…x.swift Fix encapsulated frame index offsets
Introduces the DcmDecompress executable target and its main implementation for testing and demonstrating DICOM image decompression. Updates Package.swift to include the new target, adds launch configurations for debugging and release, and cleans up .gitignore to allow .swiftpm and .vscode folders.
…mSwift into compression-support
Code Review: Compression Support PRI've completed a thorough review of this PR adding compression support to DcmSwift. Here's my comprehensive feedback: ✅ StrengthsArchitecture & Design
Code Quality
🐛 Potential Issues1. Buffer Overflow Risk in FrameIndex.swift (Lines 103-106) let nextOffset = (index + 1 < offsets.count) ? offsets[index + 1] : totalFragmentLength
let clampedNextOffset = min(max(nextOffset, startOffset), totalFragmentLength)
let length = clampedNextOffset - startOffsetThe clamping logic is good, but consider adding validation for malformed BOT tables where offsets might be corrupted or deliberately crafted to cause issues. 2. Missing Validation in PixelSequence.basicOffsetTable() 3. Error Recovery in DcmDecompress Tool ⚡ Performance Considerations
🔒 Security Concerns
🧪 Test CoverageGood Coverage:
Missing Coverage:
📝 Recommendations
// Validate offsets are monotonically increasing
for i in 1..<offsets.count {
guard offsets[i] > offsets[i-1] else {
throw FrameIndexError.invalidBOTOffsets
}
}
private let maxFrameSize = 512 * 1024 * 1024 // 512MB limit
guard length <= maxFrameSize else {
throw FrameIndexError.frameTooLarge
}
🎯 Overall AssessmentThis is a solid implementation of DICOM compression support with good architectural decisions. The main areas for improvement are around defensive programming for handling potentially malicious input and optimizing memory usage for large datasets. With the suggested security hardening and additional test coverage, this will be a robust addition to the library. The PR successfully adds valuable compression support while maintaining backward compatibility. Great work! 👍 |
|
@codex fix comments |
|
Summary
Testing
|
No description provided.