summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/H5Dio.c30
-rw-r--r--src/H5E.c2
-rw-r--r--src/H5Eint.c2
-rw-r--r--src/H5FDmulti.c4
-rw-r--r--src/H5FDsplitter.c22
-rw-r--r--src/H5Fsuper.c2
-rw-r--r--src/H5PL.c2
-rw-r--r--src/H5Pdapl.c4
-rw-r--r--src/H5Pdxpl.c2
-rw-r--r--src/H5Pencdec.c2
-rw-r--r--src/H5Plapl.c2
-rw-r--r--src/H5VLint.c2
-rw-r--r--src/H5system.c4
13 files changed, 47 insertions, 33 deletions
diff --git a/src/H5Dio.c b/src/H5Dio.c
index d1861c4..6bd4666 100644
--- a/src/H5Dio.c
+++ b/src/H5Dio.c
@@ -856,28 +856,40 @@ H5D__ioinfo_adjust(H5D_io_info_t *io_info, const H5D_t *dset, const H5S_t *file_
for (cause = 1, idx = 0;
(cause < H5D_MPIO_NO_COLLECTIVE_MAX_CAUSE) && (idx < cause_strings_len);
cause <<= 1, idx++) {
- size_t cause_strlen = HDstrlen(cause_strings[idx]);
-
if (cause & local_no_collective_cause) {
+ size_t local_buffer_space = sizeof(local_no_collective_cause_string) -
+ HDstrlen(local_no_collective_cause_string) - 1;
+
/* Check if there were any previous error messages included. If so, prepend a
* semicolon to separate the messages.
*/
- if (local_error_message_previously_written)
- HDstrncat(local_no_collective_cause_string, "; ", 2);
+ if (local_buffer_space && local_error_message_previously_written) {
+ HDstrncat(local_no_collective_cause_string, "; ", local_buffer_space);
+ local_buffer_space -= MIN(local_buffer_space, 2);
+ }
- HDstrncat(local_no_collective_cause_string, cause_strings[idx], cause_strlen);
+ if (local_buffer_space)
+ HDstrncat(local_no_collective_cause_string, cause_strings[idx],
+ local_buffer_space);
local_error_message_previously_written = TRUE;
} /* end if */
if (cause & global_no_collective_cause) {
+ size_t global_buffer_space = sizeof(global_no_collective_cause_string) -
+ HDstrlen(global_no_collective_cause_string) - 1;
+
/* Check if there were any previous error messages included. If so, prepend a
* semicolon to separate the messages.
*/
- if (global_error_message_previously_written)
- HDstrncat(global_no_collective_cause_string, "; ", 2);
-
- HDstrncat(global_no_collective_cause_string, cause_strings[idx], cause_strlen);
+ if (global_buffer_space && global_error_message_previously_written) {
+ HDstrncat(global_no_collective_cause_string, "; ", global_buffer_space);
+ global_buffer_space -= MIN(global_buffer_space, 2);
+ }
+
+ if (global_buffer_space)
+ HDstrncat(global_no_collective_cause_string, cause_strings[idx],
+ global_buffer_space);
global_error_message_previously_written = TRUE;
} /* end if */
diff --git a/src/H5E.c b/src/H5E.c
index b132103..a5a9a2e 100644
--- a/src/H5E.c
+++ b/src/H5E.c
@@ -639,7 +639,7 @@ H5E__get_class_name(const H5E_cls_t *cls, char *name, size_t size)
/* Set the user's buffer, if provided */
if (name) {
- HDstrncpy(name, cls->cls_name, MIN((size_t)(len + 1), size));
+ HDstrncpy(name, cls->cls_name, size);
if ((size_t)len >= size)
name[size - 1] = '\0';
} /* end if */
diff --git a/src/H5Eint.c b/src/H5Eint.c
index b38833f..6438cd9 100644
--- a/src/H5Eint.c
+++ b/src/H5Eint.c
@@ -129,7 +129,7 @@ H5E__get_msg(const H5E_msg_t *msg, H5E_type_t *type, char *msg_str, size_t size)
/* Copy the message into the user's buffer, if given */
if (msg_str) {
- HDstrncpy(msg_str, msg->msg, MIN((size_t)(len + 1), size));
+ HDstrncpy(msg_str, msg->msg, size);
if ((size_t)len >= size)
msg_str[size - 1] = '\0';
} /* end if */
diff --git a/src/H5FDmulti.c b/src/H5FDmulti.c
index 86f7664..e059e55 100644
--- a/src/H5FDmulti.c
+++ b/src/H5FDmulti.c
@@ -646,7 +646,7 @@ H5FD_multi_sb_encode(H5FD_t *_file, char *name /*out*/, unsigned char *buf /*out
H5Eclear2(H5E_DEFAULT);
/* Name and version number */
- strncpy(name, "NCSAmulti", (size_t)8);
+ strncpy(name, "NCSAmult", (size_t)9);
name[8] = '\0';
assert(7 == H5FD_MEM_NTYPES);
@@ -682,7 +682,7 @@ H5FD_multi_sb_encode(H5FD_t *_file, char *name /*out*/, unsigned char *buf /*out
p = buf + 8 + nseen * 2 * 8;
UNIQUE_MEMBERS (file->fa.memb_map, mt) {
size_t n = strlen(file->fa.memb_name[mt]) + 1;
- strncpy((char *)p, file->fa.memb_name[mt], n);
+ strcpy((char *)p, file->fa.memb_name[mt]);
p += n;
for (i = n; i % 8; i++)
*p++ = '\0';
diff --git a/src/H5FDsplitter.c b/src/H5FDsplitter.c
index c27cd1b..73c898a 100644
--- a/src/H5FDsplitter.c
+++ b/src/H5FDsplitter.c
@@ -340,10 +340,12 @@ H5Pset_fapl_splitter(hid_t fapl_id, H5FD_splitter_vfd_config_t *vfd_config)
HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, FAIL, "unable to allocate file access property list struct")
info->ignore_wo_errs = vfd_config->ignore_wo_errs;
- HDstrncpy(info->wo_path, vfd_config->wo_path, H5FD_SPLITTER_PATH_MAX);
- HDstrncpy(info->log_file_path, vfd_config->log_file_path, H5FD_SPLITTER_PATH_MAX);
- info->rw_fapl_id = H5P_FILE_ACCESS_DEFAULT; /* pre-set value */
- info->wo_fapl_id = H5P_FILE_ACCESS_DEFAULT; /* pre-set value */
+ HDstrncpy(info->wo_path, vfd_config->wo_path, H5FD_SPLITTER_PATH_MAX + 1);
+ info->wo_path[H5FD_SPLITTER_PATH_MAX] = '\0';
+ HDstrncpy(info->log_file_path, vfd_config->log_file_path, H5FD_SPLITTER_PATH_MAX + 1);
+ info->log_file_path[H5FD_SPLITTER_PATH_MAX] = '\0';
+ info->rw_fapl_id = H5P_FILE_ACCESS_DEFAULT; /* pre-set value */
+ info->wo_fapl_id = H5P_FILE_ACCESS_DEFAULT; /* pre-set value */
/* Set non-default channel FAPL IDs in splitter configuration info */
if (H5P_DEFAULT != vfd_config->rw_fapl_id) {
@@ -412,8 +414,8 @@ H5Pget_fapl_splitter(hid_t fapl_id, H5FD_splitter_vfd_config_t *config /*out*/)
if (NULL == (fapl_ptr = (const H5FD_splitter_fapl_t *)H5P_peek_driver_info(plist_ptr)))
HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "unable to get specific-driver info")
- HDstrncpy(config->wo_path, fapl_ptr->wo_path, H5FD_SPLITTER_PATH_MAX);
- HDstrncpy(config->log_file_path, fapl_ptr->log_file_path, H5FD_SPLITTER_PATH_MAX);
+ HDstrncpy(config->wo_path, fapl_ptr->wo_path, H5FD_SPLITTER_PATH_MAX + 1);
+ HDstrncpy(config->log_file_path, fapl_ptr->log_file_path, H5FD_SPLITTER_PATH_MAX + 1);
config->ignore_wo_errs = fapl_ptr->ignore_wo_errs;
/* Copy R/W and W/O FAPLs */
@@ -587,8 +589,8 @@ H5FD__splitter_fapl_copy(const void *_old_fa)
HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, NULL, "unable to allocate log file FAPL")
H5MM_memcpy(new_fa_ptr, old_fa_ptr, sizeof(H5FD_splitter_fapl_t));
- HDstrncpy(new_fa_ptr->wo_path, old_fa_ptr->wo_path, H5FD_SPLITTER_PATH_MAX);
- HDstrncpy(new_fa_ptr->log_file_path, old_fa_ptr->log_file_path, H5FD_SPLITTER_PATH_MAX);
+ HDstrncpy(new_fa_ptr->wo_path, old_fa_ptr->wo_path, H5FD_SPLITTER_PATH_MAX + 1);
+ HDstrncpy(new_fa_ptr->log_file_path, old_fa_ptr->log_file_path, H5FD_SPLITTER_PATH_MAX + 1);
/* Copy R/W and W/O FAPLs */
if (H5FD__copy_plist(old_fa_ptr->rw_fapl_id, &(new_fa_ptr->rw_fapl_id)) < 0)
@@ -688,8 +690,8 @@ H5FD__splitter_open(const char *name, unsigned flags, hid_t splitter_fapl_id, ha
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "unable to get VFL driver info")
/* Copy simpler info */
- HDstrncpy(file_ptr->fa.wo_path, fapl_ptr->wo_path, H5FD_SPLITTER_PATH_MAX);
- HDstrncpy(file_ptr->fa.log_file_path, fapl_ptr->log_file_path, H5FD_SPLITTER_PATH_MAX);
+ HDstrncpy(file_ptr->fa.wo_path, fapl_ptr->wo_path, H5FD_SPLITTER_PATH_MAX + 1);
+ HDstrncpy(file_ptr->fa.log_file_path, fapl_ptr->log_file_path, H5FD_SPLITTER_PATH_MAX + 1);
file_ptr->fa.ignore_wo_errs = fapl_ptr->ignore_wo_errs;
/* Copy R/W and W/O channel FAPLs. */
diff --git a/src/H5Fsuper.c b/src/H5Fsuper.c
index e7a3b53..4df0064 100644
--- a/src/H5Fsuper.c
+++ b/src/H5Fsuper.c
@@ -1043,7 +1043,7 @@ done:
HDONE_ERROR(H5E_FILE, H5E_CANTUNPIN, FAIL, "unable to unpin driver info")
/* Evict the driver info block from the cache */
- if (H5AC_expunge_entry(f, H5AC_DRVRINFO, sblock->driver_addr, H5AC__NO_FLAGS_SET) < 0)
+ if (sblock && H5AC_expunge_entry(f, H5AC_DRVRINFO, sblock->driver_addr, H5AC__NO_FLAGS_SET) < 0)
HDONE_ERROR(H5E_FILE, H5E_CANTEXPUNGE, FAIL, "unable to expunge driver info block")
} /* end if */
diff --git a/src/H5PL.c b/src/H5PL.c
index 06443f3..30b6c52 100644
--- a/src/H5PL.c
+++ b/src/H5PL.c
@@ -359,7 +359,7 @@ H5PLget(unsigned int idx, char *path_buf, size_t buf_size)
/* If the path buffer is not NULL, copy the path to the buffer */
if (path_buf) {
- HDstrncpy(path_buf, path, MIN((size_t)(path_len + 1), buf_size));
+ HDstrncpy(path_buf, path, buf_size);
if ((size_t)path_len >= buf_size)
path_buf[buf_size - 1] = '\0';
} /* end if */
diff --git a/src/H5Pdapl.c b/src/H5Pdapl.c
index 2ebdbe3..d374b25 100644
--- a/src/H5Pdapl.c
+++ b/src/H5Pdapl.c
@@ -1453,7 +1453,7 @@ H5Pget_efile_prefix(hid_t plist_id, char *prefix /*out*/, size_t size)
/* Copy to user's buffer, if given */
len = HDstrlen(my_prefix);
if (prefix) {
- HDstrncpy(prefix, my_prefix, MIN(len + 1, size));
+ HDstrncpy(prefix, my_prefix, size);
if (len >= size)
prefix[size - 1] = '\0';
} /* end if */
@@ -1543,7 +1543,7 @@ H5Pget_virtual_prefix(hid_t plist_id, char *prefix /*out*/, size_t size)
/* Copy to user's buffer, if given */
len = HDstrlen(my_prefix);
if (prefix) {
- HDstrncpy(prefix, my_prefix, MIN(len + 1, size));
+ HDstrncpy(prefix, my_prefix, size);
if (len >= size)
prefix[size - 1] = '\0';
} /* end if */
diff --git a/src/H5Pdxpl.c b/src/H5Pdxpl.c
index a0c38f8..46dc94c 100644
--- a/src/H5Pdxpl.c
+++ b/src/H5Pdxpl.c
@@ -1052,7 +1052,7 @@ H5Pget_data_transform(hid_t plist_id, char *expression /*out*/, size_t size)
/* Copy into application buffer */
len = HDstrlen(pexp);
if (expression) {
- HDstrncpy(expression, pexp, MIN(len + 1, size));
+ HDstrncpy(expression, pexp, size);
if (len >= size)
expression[size - 1] = '\0';
} /* end if */
diff --git a/src/H5Pencdec.c b/src/H5Pencdec.c
index 5b0ecb6..e2a97f8 100644
--- a/src/H5Pencdec.c
+++ b/src/H5Pencdec.c
@@ -333,7 +333,7 @@ H5P__encode_cb(H5P_genprop_t *prop, void *_udata)
/* Encode (or not, if the 'encode' flag is off) the property's name */
prop_name_len = HDstrlen(prop->name) + 1;
if (udata->encode) {
- HDstrncpy((char *)*(udata->pp), prop->name, prop_name_len);
+ HDstrcpy((char *)*(udata->pp), prop->name);
*(uint8_t **)(udata->pp) += prop_name_len;
} /* end if */
*(udata->enc_size_ptr) += prop_name_len;
diff --git a/src/H5Plapl.c b/src/H5Plapl.c
index 879e6ed..d00efaf 100644
--- a/src/H5Plapl.c
+++ b/src/H5Plapl.c
@@ -1044,7 +1044,7 @@ H5Pget_elink_prefix(hid_t plist_id, char *prefix /*out*/, size_t size)
/* Copy to user's buffer, if given */
len = HDstrlen(my_prefix);
if (prefix) {
- HDstrncpy(prefix, my_prefix, MIN(len + 1, size));
+ HDstrncpy(prefix, my_prefix, size);
if (len >= size)
prefix[size - 1] = '\0';
} /* end if */
diff --git a/src/H5VLint.c b/src/H5VLint.c
index 70c8112..b4432d0 100644
--- a/src/H5VLint.c
+++ b/src/H5VLint.c
@@ -1757,7 +1757,7 @@ H5VL__get_connector_name(hid_t id, char *name /*out*/, size_t size)
len = HDstrlen(cls->name);
if (name) {
- HDstrncpy(name, cls->name, MIN(len + 1, size));
+ HDstrncpy(name, cls->name, size);
if (len >= size)
name[size - 1] = '\0';
} /* end if */
diff --git a/src/H5system.c b/src/H5system.c
index fe379ad..9a966b0 100644
--- a/src/H5system.c
+++ b/src/H5system.c
@@ -732,8 +732,8 @@ H5_build_extpath(const char *name, char **extpath /*out*/)
HDstrncpy(full_path, cwdpath, cwdlen + 1);
if (!H5_CHECK_DELIMITER(cwdpath[cwdlen - 1]))
- HDstrncat(full_path, H5_DIR_SEPS, HDstrlen(H5_DIR_SEPS));
- HDstrncat(full_path, new_name, HDstrlen(new_name));
+ HDstrncat(full_path, H5_DIR_SEPS, path_len - (cwdlen + 1));
+ HDstrncat(full_path, new_name, path_len - (cwdlen + 1) - HDstrlen(H5_DIR_SEPS));
} /* end if */
} /* end else */