Skip to content

Commit c990e46

Browse files
committed
hl: address bmribler review comments on PR HDFGroup#6371
- Replace "NUL termination" with "null termination" in comments (H5DS.c lines 2291, 2501; H5IM.c line 1029) to match codebase convention (H5T_STR_NULLTERM) - Add clarifying comment in H5TBget_field_info else-branch explaining that name_len+1 <= HLTB_MAX_FIELD_LEN and that callers must provide buffers of at least HLTB_MAX_FIELD_LEN bytes (documented in H5TBpublic.h)
1 parent 3367470 commit c990e46

3 files changed

Lines changed: 6 additions & 3 deletions

File tree

hl/src/H5DS.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2288,7 +2288,7 @@ H5DSis_scale(hid_t did)
22882288
goto out;
22892289
}
22902290

2291-
/* Allocate one extra byte and force NUL termination so strcmp never
2291+
/* Allocate one extra byte and force null termination so strcmp never
22922292
* reads past the buffer even if some tool wrote the attribute without
22932293
* honoring the H5T_STR_NULLTERM invariant. */
22942294
buf = (char *)malloc((size_t)string_size * sizeof(char) + 1);
@@ -2498,7 +2498,7 @@ H5DS_is_reserved(hid_t did, bool *is_reserved)
24982498
/* Allocate buffer large enough to hold string */
24992499
if ((string_size = H5Tget_size(tid)) == 0)
25002500
goto error;
2501-
/* Allocate one extra byte and force NUL termination so strcmp never
2501+
/* Allocate one extra byte and force null termination so strcmp never
25022502
* reads past the buffer even if some tool wrote the attribute without
25032503
* honoring the H5T_STR_NULLTERM invariant. */
25042504
if (NULL == (buf = malloc(string_size * sizeof(char) + 1)))

hl/src/H5IM.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1026,7 +1026,7 @@ H5IM__class_attr_equals(hid_t loc_id, const char *dset_name, const char *expecte
10261026
if ((storage_size = H5Aget_storage_size(aid)) == 0)
10271027
goto out;
10281028

1029-
/* Allocate one extra byte; force NUL termination in case the attribute
1029+
/* Allocate one extra byte; force null termination in case the attribute
10301030
* was written without honoring H5T_STR_NULLTERM. */
10311031
attr_data = (char *)malloc((size_t)storage_size * sizeof(char) + 1);
10321032
if (attr_data == NULL)

hl/src/H5TB.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3038,6 +3038,9 @@ H5TBget_field_info(hid_t loc_id, const char *dset_name, char *field_names[], siz
30383038
field_names[i][HLTB_MAX_FIELD_LEN - 1] = '\0';
30393039
}
30403040
else {
3041+
/* name_len < HLTB_MAX_FIELD_LEN, so name_len + 1 <= HLTB_MAX_FIELD_LEN.
3042+
* Callers must provide buffers of at least HLTB_MAX_FIELD_LEN bytes each
3043+
* (documented in H5TBpublic.h), so this copy is within bounds. */
30413044
memcpy(field_names[i], member_name, name_len + 1);
30423045
}
30433046
H5free_memory(member_name);

0 commit comments

Comments
 (0)