diff --git a/cf b/cf index 1d123b52d..48edb83e3 100644 --- a/cf +++ b/cf @@ -1,6 +1,6 @@ #!/bin/bash #NB=1 -#DB=1 +DB=1 #X=-x #FAST=1 diff --git a/libdap2/daputil.c b/libdap2/daputil.c index 97d47b0cf..db743078e 100644 --- a/libdap2/daputil.c +++ b/libdap2/daputil.c @@ -567,7 +567,8 @@ getlimitnumber(const char* limit) case 'K': case 'k': multiplier = KILOBYTE; break; default: break; } - sscanf(limit,"%lu",&lu); + if(sscanf(limit,"%lu",&lu) != 1) + return 0; return (lu*multiplier); } diff --git a/libdap2/dceparse.c b/libdap2/dceparse.c index b9588f9bd..c7572e757 100644 --- a/libdap2/dceparse.c +++ b/libdap2/dceparse.c @@ -128,14 +128,17 @@ range(DCEparsestate* state, Object sfirst, Object sstride, Object slast) /* Note: that incoming arguments are strings; we must convert to size_t; but we do know they are legal integers or NULL */ - sscanf((char*)sfirst,"%lu",&first); /* always defined */ - if(slast != NULL) - sscanf((char*)slast,"%lu",&last); - else + if(sscanf((char*)sfirst,"%lu",&first) != 1) /* always defined */ + return NULL; + if(slast != NULL) { + if(sscanf((char*)slast,"%lu",&last) != 1) + return NULL; + } else last = first; - if(sstride != NULL) - sscanf((char*)sstride,"%lu",&stride); - else + if(sstride != NULL) { + if(sscanf((char*)sstride,"%lu",&stride) != 1) + return NULL; + } else stride = 1; /* default */ if(stride == 0) @@ -158,7 +161,8 @@ Object range1(DCEparsestate* state, Object rangenumber) { int range = -1; - sscanf((char*)rangenumber,"%u",&range); + if(sscanf((char*)rangenumber,"%u",&range) != 1) + range = -1; if(range < 0) { dceerror(state,"Illegal range index"); } @@ -199,7 +203,8 @@ array_indices(DCEparsestate* state, Object list0, Object indexno) long long start = -1; NClist* list = (NClist*)list0; if(list == NULL) list = nclistnew(); - sscanf((char*)indexno,"%lld",&start); + if(sscanf((char*)indexno,"%lld",&start) != 1) + start = -1; if(start < 0) { dceerror(state,"Illegal array index"); start = 1; diff --git a/libdispatch/nchashmap.c b/libdispatch/nchashmap.c index 36c0af05e..169fabd86 100644 --- a/libdispatch/nchashmap.c +++ b/libdispatch/nchashmap.c @@ -2090,7 +2090,7 @@ printhashmap(NC_hashmap* hm) NC_hentry e = hm->table[i]; if(e.flags == ACTIVE) { fprintf(stderr,"[%ld] flags=ACTIVE hashkey=%lu data=%p keysize=%u key=(%llu)|%s|\n", - (unsigned long)i,(unsigned long)e.hashkey,(void*)e.data,(unsigned)e.keysize,(unsigned long long)e.key,e.key); + (unsigned long)i,(unsigned long)e.hashkey,(void*)e.data,(unsigned)e.keysize,(unsigned long long)(uintptr_t)e.key,e.key); running = 0; } else if(e.flags == DELETED) { fprintf(stderr,"[%ld] flags=DELETED hashkey=%lu\n", diff --git a/libhdf5/hdf5file.c b/libhdf5/hdf5file.c index 870560685..b68934150 100644 --- a/libhdf5/hdf5file.c +++ b/libhdf5/hdf5file.c @@ -226,7 +226,9 @@ nc4_close_netcdf4_file(NC_FILE_INFO_T *h5, int abort, int extractmem) exit: /* Free the nc4_info struct; above code should have reclaimed everything else */ + if (!retval) + free(h5); return retval; } diff --git a/nc_test4/tst_filter.sh b/nc_test4/tst_filter.sh index 6e2201dc9..36df9dbde 100755 --- a/nc_test4/tst_filter.sh +++ b/nc_test4/tst_filter.sh @@ -101,7 +101,7 @@ echo "*** Testing dynamic filters using nccopy" rm -f ./unfiltered.nc ./filtered.nc ./tmp.nc ./filtered.dump ./tst_filter.txt ${NCGEN} -4 -lb -o unfiltered.nc ${srcdir}/unfiltered.cdl echo " *** Testing simple filter application" -${NCCOPY} -F "/g/var,307,9,4" unfiltered.nc filtered.nc +${NCCOPY} -M0 -F "/g/var,307,9,4" unfiltered.nc filtered.nc ${NCDUMP} -s filtered.nc > ./tst_filter.txt # Remove irrelevant -s output sclean ./tst_filter.txt ./filtered.dump @@ -119,7 +119,7 @@ echo " *** Pass: pass-thru of filters" echo " *** Testing -F none" rm -f ./tst_filter.txt ./tst_filter2.txt ./tst_filter.nc -${NCCOPY} -F none ./filtered.nc ./tst_filter.nc +${NCCOPY} -M0 -F none ./filtered.nc ./tst_filter.nc ${NCDUMP} -s tst_filter.nc > ./tst_filter.txt sed -e '/_Filter/p' -e d < ./tst_filter.txt >./tst_filter2.txt test ! -s tst_filter2.txt @@ -127,7 +127,7 @@ echo " *** Pass: -F none" echo " *** Testing -F var,none " rm -f ./tst_filter.txt ./tst_filter.nc -${NCCOPY} -F "/g/var,none" ./filtered.nc ./tst_filter.nc +${NCCOPY} -M0 -F "/g/var,none" ./filtered.nc ./tst_filter.nc ${NCDUMP} -s tst_filter.nc > ./tst_filter.txt sed -e '/_Filter/p' -e d < ./tst_filter.txt >tst_filter2.txt test ! -s tst_filter2.txt diff --git a/ncdump/nccopy.c b/ncdump/nccopy.c index 914da437b..ec9e0d9d3 100644 --- a/ncdump/nccopy.c +++ b/ncdump/nccopy.c @@ -2133,6 +2133,8 @@ main(int argc, char**argv) if(level >= 0) nc_set_log_level(level); } +#else + error("-L specified, but logging support not enabled"); #endif break; case 'F': /* optional filter spec for a specified variable */ @@ -2154,9 +2156,13 @@ main(int argc, char**argv) #else error("-F requires netcdf-4"); #endif + break; case 'M': /* set min chunk size */ #ifdef USE_NETCDF4 - option_min_chunk_bytes = atol(optarg); + if(optarg == NULL) + option_min_chunk_bytes = -1; + else + option_min_chunk_bytes = atol(optarg); if(option_min_chunk_bytes < 0) error("-M value must be non-negative integer"); break; diff --git a/ncdump/ocprint.c b/ncdump/ocprint.c index f2ffdb88a..215ef4329 100644 --- a/ncdump/ocprint.c +++ b/ncdump/ocprint.c @@ -217,7 +217,7 @@ main(int argc, char **argv) break; case 'D': { int c0; - if(strlen(optarg) == 0) usage("missing -D argument"); + if(optarg == NULL || strlen(optarg) == 0) usage("missing -D argument"); c0 = optarg[0]; if(c0 >= '0' && c0 <= '9') {/* debug level */ ocopt.debug.debuglevel = atoi(optarg); break; @@ -245,6 +245,8 @@ main(int argc, char **argv) case 'o': if(ocopt.output != NULL) fclose(ocopt.output); + if(optarg == NULL) + usage("-o does not specify a file name"); ocopt.output = fopen(optarg,"w"); if(ocopt.output == NULL) usage("-o file not writeable"); @@ -255,6 +257,8 @@ main(int argc, char **argv) break; case 'p': + if(optarg == NULL) + usage("-p does not specify an argument"); if(strcasecmp(optarg,"das")==0) ocopt.optdas=1; else if(strcasecmp(optarg,"dds")==0) ocopt.optdds=1; else if(strcasecmp(optarg,"data")==0) ocopt.optdatadds=1; @@ -280,7 +284,8 @@ main(int argc, char **argv) if(ocopt.logging) { ncloginit(); ncsetlogging(1); - nclogopen(NULL); + if(!nclogopen(NULL)) + fprintf(stderr,"Failed to open logging output\n"); } argc -= optind; @@ -479,10 +484,7 @@ processdata(OCflags flags) if(ocopt.optdatadds) { ocstat = oc_fetch(link,ocopt.url->query,OCDATADDS,flags,&dataddsroot); if(ocstat) { - if(ocopt.url->query) - fprintf(stderr,"Cannot read DATADDS: %s\n",ocopt.surl); - else - fprintf(stderr,"Cannot read DATADDS: %s\n",ocopt.surl); + fprintf(stderr,"Cannot read DATADDS: %s\n",ocopt.surl); exit(1); } if(ocopt.debug.dumpdds) @@ -556,8 +558,8 @@ printdata_container(OClink link, OCdatanode datanode, NCbytes* buffer, int istop pushstack(field); FAIL(printdata_indices(link,field,buffer,istoplevel)); popstack(); - oc_data_free(link,field); - if(stat != OC_NOERR) break; + if(oc_data_free(link,field) != OC_NOERR) + break; } return stat; } @@ -997,7 +999,7 @@ dumpdatanode(OClink link, OCdatanode datanode, size_t count, void* memory, NCbyt OCtype atomtype; OCtype octype; NCbytes* path = NULL; - char* name; + char* name = NULL; char id[1024]; char tmp[1024]; struct DUMPPATH* entry = NULL; diff --git a/oc2/dapparse.c b/oc2/dapparse.c index b7d479f63..c77579bf9 100644 --- a/oc2/dapparse.c +++ b/oc2/dapparse.c @@ -103,7 +103,7 @@ dap_unrecognizedresponse(DAPparsestate* state) unsigned int httperr = 0; int i; char iv[32]; - sscanf(state->lexstate->input,"%u ",&httperr); + (void)sscanf(state->lexstate->input,"%u ",&httperr); sprintf(iv,"%u",httperr); state->lexstate->next = state->lexstate->input; /* Limit the amount of input to prevent runaway */