summaryrefslogtreecommitdiffstats
path: root/src/H5system.c
diff options
context:
space:
mode:
authorjhendersonHDF <jhenderson@hdfgroup.org>2023-10-18 04:57:55 (GMT)
committerGitHub <noreply@github.com>2023-10-18 04:57:55 (GMT)
commit4a028905e48a40ac50442e1185e5ddff5a704ce3 (patch)
tree47b6058d3d2f8b811138af9250bf583cba70a42c /src/H5system.c
parentda9d4e78e17b7e2943c926fdd2d70031d264c8ee (diff)
downloadhdf5-4a028905e48a40ac50442e1185e5ddff5a704ce3.zip
hdf5-4a028905e48a40ac50442e1185e5ddff5a704ce3.tar.gz
hdf5-4a028905e48a40ac50442e1185e5ddff5a704ce3.tar.bz2
Sync 1.14 branch with develop (#3705)
* Address nagfor exceptions stoppage. (#3658) * added cmake ieee flag for nagfor * generalized determining the nag compiler * fixing some misc. NAG warnings * Simplify. (#3659) * Address @jhendersonHDF review * Add expedited testing support to t_filters_parallel (#3665) * Remove clang warnings (#3656) * Fixes test failure for gfortran -O2 and -O3, -fdefault-real-16 (#3662) * added cmake ieee flag for nagfor * fixes gfortran -O2 and -O3, -fdefault-real-16 * fixed sync * updated release notes * Fix link error on clang17/gfortran13/macOS-13 (#3666) (#3671) * Correct fortran CMake generator expressions (#3670) * Add AOCC GitHub Action (#3504) (#3657) * Fix uninitialized subfiling test variable (#3675) Picked up by gcc 10 on skybridge. Probably spurious, but no harm in initializing it to a "bad" value. * Add support for AOCC & Flang w/ the Autotools (#3674) * Adds a config/clang-fflags options file to support Flang * Corrects missing "-Wl," from linker options in the libtool wrappers when using Flang, the MPI Fortran compiler wrappers, and building the shared library. This would often result in unrecognized options like -soname. * Enable -nomp w/ Flang to avoid linking to the OpenMPI library. CMake can build the parallel, shared library w/ Fortran using AOCC and Flang, so no changes were needed for that build system. Fixes GitHub issues #3439, #1588, #366, #280 * Fix a strncpy call to use dest size not src (#3677) A strncpy call in a path construction call used the size of the src buffer instead of the dest buffer as the limit n. This was switched to use the dest size and properly terminate the string if truncation occurs. * Remove CANBE_UNUSED() from subfiling VFD (#3678) This macro was an attempt to quiet warnings about release mode unused variables that only appear in asserts. It resolves to a void cast, which doesn't quiet warnings when an assignment has already taken place. * Suppress MPI_Waitall warnings w/ MPICH (#3680) MPICH defines MPI_STATUSES_IGNORE (a pointer) to 1, which raises warnings w/ gcc. This is a known issue that the MPICH devs are not going to fix. See here: https://github.com/pmodels/mpich/issues/5687 This fix suppresses those issues w/ gcc * Fix a possible NULL pointer dereference in tests (#3676) The dtypes test could dereference a NULL pointer if a strdup call failed. * Fix printf warnings in t_mpi (#3679) * Fix printf warnings in t_mpi The type of MPI_Offset varies with implementation. In MPICH, it's long, which raises warnings when we attempt to use long long format specifiers. Casting to long long fixes the warnings. * Fix invalid memory access in S3 comms (#3681) In the ros3 VFD, passing an empty string parameter to an internal API call could result in accessing the -1th element of a string. This would cause failures on big-endian systems like s390x. This parameter is now checked before writing to the string. Fixes GitHub #1168 * Add Doxygen for H5Pset_fapl_sec2() (#3685) * * switch to using time function instead of date function (#3690) * Initialize API context MPI types to MPI_BYTE (#3688) * Add test info output to t_filters_parallel (#3696) * Suppress format string warnings in subfiling test (#3699) * Fix unused variable in tselect.c (#3701) * Fix unused variable warning in H5F_sfile_assert_num (#3700) * Restore floating-point suffixes in tests (#3698) A prior commit removed too many F suffixes. This restores the suffixes for float variables. * Sync with changes from develop --------- Co-authored-by: Scot Breitenfeld <brtnfld@hdfgroup.org> Co-authored-by: H. Joe Lee <hyoklee@hdfgroup.org> Co-authored-by: Allen Byrne <50328838+byrnHDF@users.noreply.github.com> Co-authored-by: Dana Robinson <43805+derobins@users.noreply.github.com>
Diffstat (limited to 'src/H5system.c')
-rw-r--r--src/H5system.c41
1 files changed, 22 insertions, 19 deletions
diff --git a/src/H5system.c b/src/H5system.c
index 7ff521e..30a89a1 100644
--- a/src/H5system.c
+++ b/src/H5system.c
@@ -620,7 +620,6 @@ H5_build_extpath(const char *name, char **extpath /*out*/)
FUNC_ENTER_NOAPI_NOINIT
- /* Sanity check */
assert(name);
assert(extpath);
@@ -634,8 +633,9 @@ H5_build_extpath(const char *name, char **extpath /*out*/)
if (H5_CHECK_ABSOLUTE(name)) {
if (NULL == (full_path = (char *)H5MM_strdup(name)))
HGOTO_ERROR(H5E_INTERNAL, H5E_NOSPACE, FAIL, "memory allocation failed");
- } /* end if */
- else { /* relative pathname */
+ }
+ else {
+ /* relative pathname */
char *retcwd;
size_t name_len;
int drive;
@@ -655,12 +655,12 @@ H5_build_extpath(const char *name, char **extpath /*out*/)
drive = HDtoupper(name[0]) - 'A' + 1;
retcwd = HDgetdcwd(drive, cwdpath, MAX_PATH_LEN);
strncpy(new_name, &name[2], name_len);
- } /* end if */
- /*
- * Windows: name[0] is a '/' or '\'
- * Get current drive
- * Unix: does not apply
- */
+ }
+ /*
+ * Windows: name[0] is a '/' or '\'
+ * Get current drive
+ * Unix: does not apply
+ */
else if (H5_CHECK_ABS_PATH(name) && (0 != (drive = HDgetdrive()))) {
snprintf(cwdpath, MAX_PATH_LEN, "%c:%c", (drive + 'A' - 1), name[0]);
retcwd = cwdpath;
@@ -670,28 +670,32 @@ H5_build_extpath(const char *name, char **extpath /*out*/)
else {
retcwd = HDgetcwd(cwdpath, MAX_PATH_LEN);
strncpy(new_name, name, name_len);
- } /* end if */
+ }
if (retcwd != NULL) {
size_t cwdlen;
size_t path_len;
- assert(cwdpath);
cwdlen = strlen(cwdpath);
- assert(cwdlen);
- assert(new_name);
+ if (cwdlen == 0)
+ HGOTO_ERROR(H5E_INTERNAL, H5E_BADVALUE, FAIL, "cwd length is zero");
path_len = cwdlen + strlen(new_name) + 2;
if (NULL == (full_path = (char *)H5MM_malloc(path_len)))
HGOTO_ERROR(H5E_INTERNAL, H5E_NOSPACE, FAIL, "memory allocation failed");
- strncpy(full_path, cwdpath, cwdlen + 1);
+ /* path_len will always be greater than zero, so no check before
+ * setting the terminal NUL byte of full_path
+ */
+ strncpy(full_path, cwdpath, path_len);
+ full_path[path_len - 1] = '\0';
+
if (!H5_CHECK_DELIMITER(cwdpath[cwdlen - 1]))
strncat(full_path, H5_DIR_SEPS, path_len - (cwdlen + 1));
strncat(full_path, new_name, path_len - (cwdlen + 1) - strlen(H5_DIR_SEPS));
- } /* end if */
- } /* end else */
+ }
+ }
- /* strip out the last component (the file name itself) from the path */
+ /* Strip out the last component (the file name itself) from the path */
if (full_path) {
char *ptr = NULL;
@@ -699,10 +703,9 @@ H5_build_extpath(const char *name, char **extpath /*out*/)
assert(ptr);
*++ptr = '\0';
*extpath = full_path;
- } /* end if */
+ }
done:
- /* Release resources */
if (cwdpath)
H5MM_xfree(cwdpath);
if (new_name)