mirror of
https://github.com/Unidata/netcdf-c.git
synced 2025-04-06 18:00:24 +08:00
Re: github issues
https://github.com/Unidata/netcdf-c/issues/917 https://github.com/Unidata/netcdf-c/issues/915 Fix following memory errors: 1. global_buffer_overflow 2. nc4_att_list_add
This commit is contained in:
parent
8cf597c8fb
commit
42e8028726
4
cf
4
cf
@ -2,7 +2,7 @@
|
||||
#NB=1
|
||||
DB=1
|
||||
#X=-x
|
||||
FAST=1
|
||||
#FAST=1
|
||||
#PROF=1
|
||||
|
||||
HDF5=1
|
||||
@ -10,7 +10,7 @@ DAP=1
|
||||
#SZIP=1
|
||||
#HDF4=1
|
||||
#PNETCDF=1
|
||||
PAR4=1
|
||||
#PAR4=1
|
||||
|
||||
if test $# != 0 ; then
|
||||
cmds=$@
|
||||
|
@ -2072,22 +2072,6 @@ next: continue;
|
||||
fflush(stderr);
|
||||
}
|
||||
|
||||
|
||||
/* Handle the data key part */
|
||||
static const char*
|
||||
keystr(NC_hentry* e)
|
||||
{
|
||||
static char s[sizeof(uintptr_t)+1];
|
||||
size_t x = sizeof(uintptr_t);
|
||||
if(e == NULL) return "<NULL>";
|
||||
if(e->keysize <= x) {
|
||||
memset(s,0,sizeof(s));
|
||||
memcpy(s,(const char*)(&e->key),e->keysize);
|
||||
return s;
|
||||
} else
|
||||
return (e->key?(const char*)(e->key):"<NULL>");
|
||||
}
|
||||
|
||||
void
|
||||
printhashmap(NC_hashmap* hm)
|
||||
{
|
||||
@ -2105,8 +2089,8 @@ printhashmap(NC_hashmap* hm)
|
||||
for(i=0;i<hm->alloc;i++) {
|
||||
NC_hentry e = hm->table[i];
|
||||
if(e.flags == ACTIVE) {
|
||||
fprintf(stderr,"[%ld] flags=ACTIVE hashkey=%lu data=%p keysize=%u key=|%s|\n",
|
||||
(unsigned long)i,(unsigned long)e.hashkey,(void*)e.data,(unsigned)e.keysize,e.key);
|
||||
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);
|
||||
running = 0;
|
||||
} else if(e.flags == DELETED) {
|
||||
fprintf(stderr,"[%ld] flags=DELETED hashkey=%lu\n",
|
||||
|
@ -738,8 +738,6 @@ NC4_put_att(int ncid, int varid, const char *name, nc_type file_type,
|
||||
LOG((3, "adding attribute %s to the list...", norm_name));
|
||||
if ((ret = nc4_att_list_add(attlist, norm_name, &att)))
|
||||
BAIL (ret);
|
||||
if (!(att->hdr.name = strdup(norm_name)))
|
||||
return NC_ENOMEM;
|
||||
}
|
||||
|
||||
/* Now fill in the metadata. */
|
||||
|
@ -507,9 +507,11 @@ NC4_def_var(int ncid, const char *name, nc_type xtype,
|
||||
{
|
||||
size_t len;
|
||||
char name[NC_MAX_NAME+1];
|
||||
char* atomname = nc4_atomic_name[xtype];
|
||||
size_t namelen = strlen(atomname);
|
||||
memcpy(name,atomname,namelen);
|
||||
name[namelen] = '\0';
|
||||
nc4_get_typelen_mem(h5,xtype,&len);
|
||||
memcpy(name,nc4_atomic_name[xtype],NC_MAX_NAME);
|
||||
name[NC_MAX_NAME] = '\0';
|
||||
if((retval = nc4_type_new(grp,len,name,xtype,&type_info)))
|
||||
BAIL(retval);
|
||||
type_info->endianness = NC_ENDIAN_NATIVE;
|
||||
|
@ -195,6 +195,7 @@ ncindexrebuild(NCindex* index)
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
if(contents != NULL) free(contents);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user