Force attribute value to be in-range vs causing error.

re: https://github.com/conda-forge/libnetcdf-feedstock/pull/26
(Note: note conda-forge, not Unidata).
Revert dap2 code to 4.4.1.1. behavior so that attribute values
are forced into a specific range. Current behavior generates
error if an attribute value is out of range.
This commit is contained in:
Dennis Heimbigner 2017-10-23 18:27:43 -06:00
parent a2964f5fb0
commit 338f958e46

View File

@ -217,7 +217,8 @@ dapcvtattrval(nc_type etype, void* dst, NClist* src)
#ifdef _MSC_VER
_ASSERTE(_CrtCheckMemory());
#endif
if(ival < 0 || ival > NC_MAX_UBYTE) ok = 0;
/* For back compatibility, we allow any value, but force conversion */
ival = (ival & 0xFF);
*p = (char)ival;
} break;
case NC_CHAR: {
@ -246,7 +247,8 @@ 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;
/* For back compatibility, we allow any value, but force conversion */
uval = (uval & 0xFF);
*p = (unsigned char)uval;
#else
ok = sscanf(s,"%hhu%n",p,&nread);