From 338f958e46e5f6bb8040a417bdeb8214928a5cb7 Mon Sep 17 00:00:00 2001 From: Dennis Heimbigner Date: Mon, 23 Oct 2017 18:27:43 -0600 Subject: [PATCH] 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. --- libdap2/dapcvt.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libdap2/dapcvt.c b/libdap2/dapcvt.c index 65cc69278..b0e758322 100644 --- a/libdap2/dapcvt.c +++ b/libdap2/dapcvt.c @@ -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);