New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Various fixes #1640
Various fixes #1640
Conversation
I can split this into multiple PRs if that is preferred as well. |
@@ -190,9 +190,6 @@ | |||
/* Define to 1 if you have the `curl' library (-lcurl). */ | |||
#cmakedefine H5_HAVE_LIBCURL @H5_HAVE_LIBCURL@ | |||
|
|||
/* Define to 1 if you have the `dl' library (-ldl). */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We still maintain two build systems: CMake and autotools/autoconf.
This file needs to remain in sync with the file generated by autoconf until such time that we no longer support autoconf.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing cares if this define is present or not, so it isn't doing anything in the header.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We keep this file in sync with the one produced by Autoconf so it's easier to eyeball them to make sure we aren't missing something in the other build system.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A lot of these header files are useless, though, and have already been removed from configure.ac.
if (MINGW OR NOT WINDOWS) | ||
CHECK_LIBRARY_EXISTS_CONCAT ("m" ceil ${HDF_PREFIX}_HAVE_LIBM) | ||
CHECK_LIBRARY_EXISTS_CONCAT ("dl" dlopen ${HDF_PREFIX}_HAVE_LIBDL) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does mingw not need these? Mingw generates windows objects on linux, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but there is no libdl
in MinGW as it uses LoadLibrary
. Maybe you're thinking of Cygwin?
HDstrncat(full_path, H5_DIR_SEPS, path_len - (cwdlen + 1)); | ||
HDstrncat(full_path, new_name, path_len - (cwdlen + 1) - HDstrlen(H5_DIR_SEPS)); | ||
HDstrcat(full_path, H5_DIR_SEPS); | ||
HDstrcat(full_path, new_name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change seems like it will possibly be reintroducing a vulnerability by not calculating how much space is left in full_path
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The correct length is allocated right above this.
@@ -1043,76 +1043,40 @@ target_compile_options(H5detect | |||
) | |||
set (lib_prog_deps ${lib_prog_deps} H5detect) | |||
|
|||
# check if a pregenerated H5Tinit.c file is present | |||
if (NOT EXISTS "${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check is if we are cross-compiling with a pre-generated file - because the host system cannot generate a file for the target system. How is it handled in your changes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hrm. This causes problems because rerunning the configure after the build happens causes it to detect the "pre-generated" file and confuses reconfigures. I think another approach for cross-compilations where the source directory gets the to-be-used file is used instead of overloading the existence of the output like this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there is a cross-compiling emulator available (e.g., Wine when doing MinGW on Linux), it will be able to run the binary. So it's not just "cross compiling, therefore impossible".
${HDF5_SOURCE_DIR}/bin/batch/${HDF5_BATCH_H5DETECT_SCRIPT}.in.cmake | ||
${HDF5_BINARY_DIR}/${HDF5_BATCH_H5DETECT_SCRIPT} ESCAPE_QUOTES @ONLY | ||
) | ||
add_custom_command ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this form of add_custom_command work correctly with the ninja system?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it's what I tested it with. I'm not really sure why the stamp gymnastics were done previously as they just overcomplicated it instead of making anything actually work (AFAICT).
@@ -310,6 +310,7 @@ | |||
#include <string.h> | |||
#include <errno.h> | |||
#include <stdlib.h> | |||
#include <stdint.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes should be made in H5LTanalyze.l. H5LTanalyze.c is generated by lex from H5LTanalyze.l.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The commit message mentions that flex
generates the bits that it doesn't include for. I can include it there, but flex
should really be adding the include for its generated code. I'll add a comment there to that effect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is fixed in develop
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The proposed changes need justification/discussion
HDstrncat(full_path, H5_DIR_SEPS, path_len - (cwdlen + 1)); | ||
HDstrncat(full_path, new_name, path_len - (cwdlen + 1) - HDstrlen(H5_DIR_SEPS)); | ||
HDstrcat(full_path, H5_DIR_SEPS); | ||
HDstrcat(full_path, new_name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about a defensive rewrite using snprintf
?
int rc = snprintf(full_path, path_len, "%s%s%s", cwdpath,
H5_CHECK_DELIMITER(cwdpath[cwdlen - 1]) ? "" : H5_DIR_SEPS,
new_name);
if (rc < 0 || (size_t)rc >= path_len) {
HGOTO_ERROR(H5E_INTERNAL, H5E_CANTCOPY, FAIL,
"buffer would overflow")
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that would certainly be a bit less prone to error, though maybe a little bit less clean. I'd be for doing that though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm all for using safer C string manip functions :) .
However, if there's an overflow, that is a logic error in this function as path_len
is calcuated right above.
These calls did `strop(dst, src, strlen(src))` in some form or another. The size to these operations is the size of the *destination* buffer; the source size is implicit with `NUL` termination.
Other locations check if it is defined and in cases where it is not available, it is undefined, not 0.
These were checked for at configure time, but nothing in the code cared about their results. Remove the checks.
This is actually a bug in flex, not the grammar file.
Please see the commit messages. Are there any that are deficient? |
In release builds, `assert`-like macros disappear and cause some variables to be detected as unused. Add a "fake" usage to let the compiler know that things are as intended.
Oh, there's stuff to perserve here. |
Yeah, I've been meaning to go over this again to see what's up with all the changes. |
@@ -656,6 +656,7 @@ H5T__ref_mem_write(H5VL_object_t *src_file, const void *src_buf, size_t src_size | |||
HDassert(dst_buf); | |||
HDassert(dst_size == H5T_REF_MEM_SIZE); | |||
HDcompile_assert(sizeof(*dst_ref) == sizeof(tmp_ref)); | |||
(void)dst_size; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is fixed in develop
@@ -590,6 +590,8 @@ H5O__shared_copy_file(H5F_t H5_ATTR_NDEBUG_UNUSED *file_src, H5F_t *file_dst, | |||
HDassert(shared_dst); | |||
HDassert(recompute_size); | |||
HDassert(cpy_info); | |||
(void)file_src; | |||
(void)cpy_info; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in develop
@@ -3045,6 +3045,8 @@ H5O__free(H5O_t *oh, hbool_t force) | |||
oh->ndecode_dirtied--; | |||
else if (!force) | |||
HDassert(oh->mesg[u].dirty == 0); | |||
#else | |||
(void)force; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in develop
@@ -750,6 +752,7 @@ H5O__cache_chk_deserialize(const void *image, size_t len, void *_udata, hbool_t | |||
HDassert(udata); | |||
HDassert(udata->oh); | |||
HDassert(dirty); | |||
(void)len; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
len is used below
@@ -302,6 +303,7 @@ H5O__cache_deserialize(const void *image, size_t len, void *_udata, hbool_t *dir | |||
HDassert(udata->common.f); | |||
HDassert(udata->common.cont_msg_info); | |||
HDassert(dirty); | |||
(void)len; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
len is used below
@@ -197,6 +197,7 @@ H5O__cache_get_final_load_size(const void *image, size_t H5_ATTR_NDEBUG_UNUSED i | |||
HDassert(udata); | |||
HDassert(actual_len); | |||
HDassert(*actual_len == image_len); | |||
(void)image_len; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in develop
} /* end if */ | ||
} /* end if */ | ||
#else | ||
(void)f; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in develop
@@ -1085,6 +1085,7 @@ H5FD__sec2_ctl(H5FD_t *_file, uint64_t op_code, uint64_t flags, const void H5_AT | |||
|
|||
/* Sanity checks */ | |||
HDassert(file); | |||
(void)file; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in develop
uint64_t * elmt = (uint64_t *)_elmt; /* Convenience pointer to native elements */ | ||
const uint8_t *raw = (const uint8_t *)_raw; /* Convenience pointer to raw elements */ | ||
#else | ||
(void)_ctx; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in develop
@@ -614,6 +614,7 @@ H5D__contig_may_use_select_io(const H5D_io_info_t *io_info, H5D_io_op_type_t op_ | |||
HDassert(io_info); | |||
HDassert(dataset); | |||
HDassert(op_type == H5D_IO_OP_READ || op_type == H5D_IO_OP_WRITE); | |||
(void)dataset; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in develop
@@ -8114,6 +8114,7 @@ H5D__chunk_iter(const H5D_t *dset, H5D_chunk_iter_op_t op, void *op_data) | |||
HDassert(layout); | |||
HDassert(rdcc); | |||
HDassert(H5D_CHUNKED == layout->type); | |||
(void)layout; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in develop
@@ -2148,6 +2148,7 @@ H5A__attr_copy_file(const H5A_t *attr_src, H5F_t *file_dst, hbool_t *recompute_s | |||
HDassert(file_dst); | |||
HDassert(cpy_info); | |||
HDassert(!cpy_info->copy_without_attr); | |||
(void)cpy_info; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in develop
I think we've pulled everything we can out of this. The one thing that is left is the cross-compiling bits, but I'm going to leave that to a future discussion. |
Various fixes from VTK's bundled HDF5 that we've applied that seems relevant for upstream.