Skip to content

Commit a425123

Browse files
authored
Leave room in _DcmAttribute to NUL-terminate a 63-character keyword (#100)
"FrameOfReferenceToDisplayedCoordinateSystemTransformationMatrix" is 63 characters and we need room for the trailing NUL. While the compiler would have added a trailing 0 byte anyway to maintain struct alignment, reading the string would invoke undefined behavior. Fixes a warning on GCC 15: ../src/dicom-dict-tables.c:3296:33: warning: initializer-string for array of ‘char’ truncates NUL terminator but destination lacks ‘nonstring’ attribute (64 chars into 63 available) [-Wunterminated-string-initialization] 3296 | {0X0070030B, DCM_VR_TAG_FD, "FrameOfReferenceToDisplayedCoordinateSystemTransformationMatrix"}
1 parent de8c1bb commit a425123

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
## main
22

3+
* fix one-byte overread into struct padding [bgilbert]
4+
35
## 1.2.0, 09/04/2025
46

57
* fix build with uthash \< 2.3.0 [bgilbert]

src/dicom-dict-tables.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ typedef enum _DcmVRTag {
6868
struct _DcmAttribute {
6969
uint32_t tag;
7070
DcmVRTag vr_tag;
71-
char keyword[63];
71+
char keyword[64];
7272
};
7373

7474
extern const struct _DcmAttribute dcm_attribute_table[];

0 commit comments

Comments
 (0)