Skip to content
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

Undefined behavior in ncx.m4 #2799

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions config.h.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
11 changes: 7 additions & 4 deletions libsrc/ncx.m4
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ ifdef(`PNETCDF',`
`#'if HAVE_CONFIG_H
`#'include <config.h>
`#'endif')

#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Expand Down Expand Up @@ -527,8 +527,10 @@ swapn8b(void *dst, const void *src, IntType nn)
uint64_t *ip = (uint64_t*) src;
for (i=0; i<nn; i++) {
/* copy over, make the below swap in-place */
op[i] = ip[i];
op[i] = SWAP8(op[i]);
uint64_t temp;
memcpy(&temp, (uint64_t*)src + i * sizeof(uint64_t), sizeof(uint64_t));
temp = SWAP8(temp);
memcpy((uint64_t*)dst + i * sizeof(uint64_t), &temp, sizeof(uint64_t));
}
#endif

Expand Down Expand Up @@ -760,7 +762,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
Expand Down
Loading