From ce33d888a11d1bd38b2c03904e3891988e590ce6 Mon Sep 17 00:00:00 2001 From: Ward Fisher Date: Tue, 14 Nov 2023 15:43:58 -0700 Subject: [PATCH 1/4] Add missing ERANGE_FILL to cmake-generated config.h. Include config.h in ncx.c. --- config.h.cmake.in | 6 ++++++ libsrc/ncx.m4 | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/config.h.cmake.in b/config.h.cmake.in index 04d876ff17..941240390a 100644 --- a/config.h.cmake.in +++ b/config.h.cmake.in @@ -118,6 +118,12 @@ are set when opening a binary file on Windows. */ /* if true, build byte-range Client */ #cmakedefine ENABLE_BYTERANGE 1 +/* if true, enable ERANGE fill */ +#cmakedefine ENABLE_ERANGE_FILL 1 +#ifdef ENABLE_ERANGE_FILL +#define ERANGE_FILL 1 +#endif + /* if true, use hdf5 S3 virtual file reader */ #cmakedefine ENABLE_HDF5_ROS3 1 diff --git a/libsrc/ncx.m4 b/libsrc/ncx.m4 index c8ea6df416..48b8cf4ad2 100644 --- a/libsrc/ncx.m4 +++ b/libsrc/ncx.m4 @@ -39,7 +39,7 @@ ifdef(`PNETCDF',` `#'if HAVE_CONFIG_H `#'include `#'endif') - +#include #include #include #include From b9039a2a78c2023db84ed4021c4ea59f5363f192 Mon Sep 17 00:00:00 2001 From: Ward Fisher Date: Tue, 14 Nov 2023 16:10:13 -0700 Subject: [PATCH 2/4] First initial stab at fixing an issue in ncx.m4 based on undefined behavior. --- libsrc/ncx.m4 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libsrc/ncx.m4 b/libsrc/ncx.m4 index 48b8cf4ad2..297f08063e 100644 --- a/libsrc/ncx.m4 +++ b/libsrc/ncx.m4 @@ -760,7 +760,8 @@ APIPrefix`x_put_'NC_TYPE($1)_$2(void *xp, const $2 *ip, void *fillp) #endif', `$2', `float', `if (*ip > (double)Xmax($1) || *ip < FXmin($1)) { FillValue($1, &xx) - DEBUG_ASSIGN_ERROR(err, NC_ERANGE) + /* DEBUG_ASSIGN_ERROR(err, NC_ERANGE) */ + return NC_ERANGE; } #ifdef ERANGE_FILL else From d96e8d1526ee916d187b25f2f2f42827a2ac234c Mon Sep 17 00:00:00 2001 From: Ward Fisher Date: Tue, 14 Nov 2023 17:14:23 -0700 Subject: [PATCH 3/4] Fix a byte misalignment issue. --- libsrc/ncx.m4 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libsrc/ncx.m4 b/libsrc/ncx.m4 index 297f08063e..dc8c48bc57 100644 --- a/libsrc/ncx.m4 +++ b/libsrc/ncx.m4 @@ -527,8 +527,10 @@ swapn8b(void *dst, const void *src, IntType nn) uint64_t *ip = (uint64_t*) src; for (i=0; i Date: Wed, 15 Nov 2023 15:52:36 -0700 Subject: [PATCH 4/4] Update casting for Visual Studio purposes. --- libsrc/ncx.m4 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libsrc/ncx.m4 b/libsrc/ncx.m4 index dc8c48bc57..275fc0ddd5 100644 --- a/libsrc/ncx.m4 +++ b/libsrc/ncx.m4 @@ -528,9 +528,9 @@ swapn8b(void *dst, const void *src, IntType nn) for (i=0; i