Followon to

re: https://github.com/Unidata/netcdf-c/issues/365

1. Added to RELEASENOTES.md
2. Add a range check to more closely
   mimic unix sscanf
3. locate and fix same sscanf problems in ncgen/cvt.c

Still need a stable url for a test case.
This commit is contained in:
Dennis Heimbigner 2017-02-20 13:19:25 -07:00
parent 96bd037560
commit f71b695530
4 changed files with 13 additions and 45 deletions

View File

@ -11,6 +11,7 @@ This file contains a high-level description of this package's evolution. Release
## 4.4.2 - TBD
* [Bug] Addressed conversion problem with Windows sscanf. See [GitHub #365](https://github.com/Unidata/netcdf-c/issues/365) for more information.
* [Enhancement] Added support for HDF5 collective metadata operations when available. Patch submitted by Greg Sjaardema, see [Pull request #335](https://github.com/Unidata/netcdf-c/pull/335) for more information.
* [Bug] Addressed a potential type punning issue. See [GitHub #351](https://github.com/Unidata/netcdf-c/issues/351) for more information.
* [Bug] Addressed an issue where netCDF wouldn't build on Windows systems using MSVC 2012. See [GitHub #304](https://github.com/Unidata/netcdf-c/issues/304) for more information.

View File

@ -1,44 +0,0 @@
# Is netcdf-4 and/or DAP enabled?
NC4=1
DAP=1
# Is visual studio being used?
VS=yes
#CYGWIN=yes
if test "x$VS" = x ; then
#CC=mpicc
CC=gcc
else
VSSTRING="Visual Studio 12 2013 Win64"
G="-G\"$VSSTRING\""
fi
export CC
FLAGS="-DCMAKE_PREFIX_PATH=c:/tools/nccmake"
FLAGS="$FLAGS -DCMAKE_INSTALL_PREFIX=d:/ignore"
if test "x$DAP" = x ; then
FLAGS="$FLAGS -DENABLE_DAP=false"
fi
if test "x$NC4" = x ; then
FLAGS="$FLAGS -DENABLE_NETCDF_4=false"
fi
FLAGS="$FLAGS -DENABLE_CONVERSION_WARNINGS=false"
FLAGS="$FLAGS -DENABLE_DAP_REMOTE_TESTS=true"
FLAGS="$FLAGS -DENABLE_TESTS=true"
FLAGS="$FLAGS -DENABLE_EXAMPLES=false"
#FLAGS="$FLAGS -DENABLE_DAP4=true"
rm -fr build
mkdir build
cd build
cmake $FLAGS ${ZLIB} ${HDF5} ${CURL} ..
# We must use Release config here because Debug will invoke a runtime dialog box.
# If missing, appears to default to Debug
#CFG="--config RelWithDebInfo"
#cmake --build . ${CFG}
#cmake --build . ${CFG} --target RUN_TESTS

View File

@ -215,6 +215,7 @@ dapcvtattrval(nc_type etype, void* dst, NClist* src)
int ival;
ok = sscanf(s,"%d%n",&ival,&nread);
_ASSERTE(_CrtCheckMemory());
if(ival < NC_MIN_BYTE || ival > NC_MAX_BYTE) ok = 0;
*p = (char)ival;
#else
ok = sscanf(s,"%hhu%n",p,&nread);
@ -246,6 +247,7 @@ dapcvtattrval(nc_type etype, void* dst, NClist* src)
unsigned int uval;
ok = sscanf(s,"%u%n",&uval,&nread);
_ASSERTE(_CrtCheckMemory());
if(uval > NC_MAX_UBYTE) ok = 0;
*p = (unsigned char)uval;
#else
ok = sscanf(s,"%hhu%n",p,&nread);

View File

@ -18,7 +18,9 @@ convert1(NCConstant* src, NCConstant* dst)
Constvalue tmp;
unsigned char* bytes = NULL;
size_t bytelen;
#ifdef _MSC_VER
int byteval;
#endif
dst->lineno = src->lineno;
/* Need to translate all possible sources to all possible sinks.*/
@ -405,10 +407,17 @@ case CASE(NC_DOUBLE,NC_DOUBLE):
break;
/* Conversion of a string to e.g. an integer should be what?*/
#ifdef _MSC_VER
case CASE(NC_STRING,NC_BYTE):
sscanf(src->value.stringv.stringv,"%d",&byteval); tmp.int8v = (char)byteval; break;
case CASE(NC_STRING,NC_UBYTE):
sscanf(src->value.stringv.stringv,"%d",&byteval); tmp.uint8v = (unsigned char)byteval; break;
#else
case CASE(NC_STRING,NC_BYTE):
sscanf(src->value.stringv.stringv,"%hhd",&tmp.int8v); break;
case CASE(NC_STRING,NC_UBYTE):
sscanf(src->value.stringv.stringv,"%hhu",&tmp.uint8v); break;
#endif
case CASE(NC_STRING,NC_USHORT):
sscanf(src->value.stringv.stringv,"%hu",&tmp.uint16v); break;
case CASE(NC_STRING,NC_UINT):