From d91ccdf54cfeb84ac25baf7c3dd252769bea89de Mon Sep 17 00:00:00 2001 From: Dennis Heimbigner Date: Thu, 28 Jan 2016 22:18:51 -0700 Subject: [PATCH] Github issue: https://github.com/Unidata/netcdf-c/issues/206 Re e-eupport VGQ-678069 It was noticed that an attribute value of "nan." was being treated as legal (it should be "nan"). The reason is that sscanf was not be checked to see that all the attribute value characters were being read. Solution is to verify that all characters were being consumed. --- libdap2/dapcvt.c | 33 +++++++++++++++++---------------- libdap2/env | 14 +++++++++++--- libdap2/ncd2dispatch.c | 8 +++++--- 3 files changed, 33 insertions(+), 22 deletions(-) diff --git a/libdap2/dapcvt.c b/libdap2/dapcvt.c index 394f30c95..b67ff846f 100644 --- a/libdap2/dapcvt.c +++ b/libdap2/dapcvt.c @@ -203,8 +203,9 @@ dapcvtattrval(nc_type etype, void* dst, NClist* src) char* dstmem = (char*)dst; for(i=0;isubstrate,varid,att->name,strlen(newstring),newstring); free(newstring); + if(ncstat) goto done; } else { nc_type atype; unsigned int typesize; @@ -955,13 +956,14 @@ buildattribute(NCDAPCOMMON* dapcomm, NCattribute* att, nc_type vartype, int vari #ifdef _MSC_VER _ASSERTE(_CrtCheckMemory()); #endif + if(ncstat) {nullfree(mem); goto done;} ncstat = nc_put_att(drno->substrate,varid,att->name,atype,nvalues,mem); #ifdef _MSC_VER _ASSERTE(_CrtCheckMemory()); #endif - if (mem != NULL) - free(mem); - } + if(ncstat) {nullfree(mem); goto done;} + } +done: return THROW(ncstat); }