Merge branch 'master' into ejh_udf

This commit is contained in:
Ed Hartnett 2018-06-08 14:49:15 -06:00 committed by GitHub
commit 29ce3b7d8c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 307 additions and 276 deletions

View File

@ -92,7 +92,8 @@ NC_authsetup(NCauth* auth, NCURI* uri)
if(uri != NULL)
uri_hostport = NC_combinehostport(uri);
else
return NC_EDAP; /* Generic EDAP error. */
setdefaults(auth);
/* Note, we still must do this function even if
@ -136,6 +137,7 @@ NC_authsetup(NCauth* auth, NCURI* uri)
NC_rclookup("HTTP.SSL.VERIFYPEER",uri_hostport));
setauthfield(auth,"HTTP.NETRC",
NC_rclookup("HTTP.NETRC",uri_hostport));
{ /* Handle various cases for user + password */
/* First, see if the user+pwd was in the original url */
char* user = NULL;
@ -155,13 +157,14 @@ NC_authsetup(NCauth* auth, NCURI* uri)
const char* userpwd = NC_rclookup("HTTP.CREDENTIALS.USERPASSWORD",uri_hostport);
if(userpwd != NULL) {
ret = NC_parsecredentials(userpwd,&user,&pwd);
if(ret) return ret;
if(ret) {nullfree(uri_hostport); return ret;}
}
}
setauthfield(auth,"HTTP.USERNAME",user);
setauthfield(auth,"HTTP.PASSWORD",pwd);
nullfree(user);
nullfree(pwd);
nullfree(uri_hostport);
}
return (ret);
}
@ -356,8 +359,10 @@ NC_parsecredentials(const char* userpwd, char** userp, char** pwdp)
if(user == NULL)
return NC_ENOMEM;
pwd = strchr(user,':');
if(pwd == NULL)
if(pwd == NULL) {
free(user);
return NC_EINVAL;
}
*pwd = '\0';
pwd++;
if(userp)
@ -380,4 +385,3 @@ setdefaults(NCauth* auth)
}
}
}

View File

@ -2325,13 +2325,19 @@ NC_open(const char *path0, int cmode, int basepe, size_t *chunksizehintp,
#ifdef USE_CDF5
cdf5built = 1;
#endif
if(!hdf5built && model == NC_FORMATX_NC4)
if(!hdf5built && model == NC_FORMATX_NC4) {
free(path);
return NC_ENOTBUILT;
if(!hdf4built && model == NC_FORMATX_NC4 && version == 4)
}
if(!hdf4built && model == NC_FORMATX_NC4 && version == 4) {
free(path);
return NC_ENOTBUILT;
if(!cdf5built && model == NC_FORMATX_NC3 && version == 5)
}
if(!cdf5built && model == NC_FORMATX_NC3 && version == 5) {
free(path);
return NC_ENOTBUILT;
}
}
/* Force flag consistentcy */
if(model == NC_FORMATX_NC4 || model == NC_FORMATX_NC_HDF4 || model == NC_FORMATX_DAP4 ||

View File

@ -196,10 +196,9 @@ static void
rctrim(char* text)
{
char* p = text;
size_t len;
size_t len = 0;
int i;
len = strlen(text);
/* locate first non-trimchar */
for(;*p;p++) {
if(strchr(TRIMCHARS,*p) == NULL) break; /* hit non-trim char */
@ -297,6 +296,7 @@ rccompile(const char* path)
char* rtag = strchr(line,RTAG);
if(rtag == NULL) {
nclog(NCLOGERR, "Malformed [url] in %s entry: %s",path,line);
free(triple);
continue;
}
line = rtag + 1;
@ -305,6 +305,7 @@ rccompile(const char* path)
if(uri) ncurifree(uri);
if(ncuriparse(url,&uri) != NCU_OK) {
nclog(NCLOGERR, "Malformed [url] in %s entry: %s",path,line);
free(triple);
continue;
}
ncbytesclear(tmp);
@ -441,4 +442,3 @@ storedump(char* msg, NClist* triples)
fflush(stderr);
}
#endif

View File

@ -164,7 +164,11 @@ int nc_utf8_to_utf16(const unsigned char* s8, unsigned short** utf16p, size_t* l
}
}
*p16++ = (unsigned short)0;
if(utf16p) *utf16p = utf16;
if(utf16p)
*utf16p = utf16;
else
free(utf16);
if(len16p) *len16p = len16;
done:
if(ncstat) free(utf16);

View File

@ -1,7 +1,7 @@
/*! \file
Functions for inquiring about variables.
Copyright 2010 University Corporation for Atmospheric
Copyright 2018 University Corporation for Atmospheric
Research/Unidata. See COPYRIGHT file for more info.
*/
@ -38,6 +38,7 @@ ignored_if_null.
\returns ::NC_NOERR No error.
\returns ::NC_EBADID Bad ncid.
\returns ::NC_ENOTVAR Invalid variable ID.
\section nc_inq_varid_example4 Example

View File

@ -368,7 +368,10 @@ ncuriparse(const char* uri0, NCURI** durip)
duri->fragment = nulldup(tmp.fragment);
duri->fraglist = tmp.fraglist; tmp.fraglist = NULL;
duri->querylist = tmp.querylist; tmp.querylist = NULL;
if(durip) *durip = duri;
if(durip)
*durip = duri;
else
free(duri);
#ifdef NCXDEBUG
{
@ -388,6 +391,7 @@ ncuriparse(const char* uri0, NCURI** durip)
done:
if(uri != NULL)
free(uri);
freestringlist(params);
freestringlist(querylist);
freestringvec(tmp.fraglist);

View File

@ -1290,8 +1290,10 @@ nc4_get_vara(NC *nc, int ncid, int varid, const size_t *startp,
} else {
*(char **)filldata = NULL;
}
} else
} else {
if(fillvalue)
memcpy(filldata, fillvalue, file_type_size);
}
filldata = (char *)filldata + file_type_size;
}
}

View File

@ -1203,7 +1203,10 @@ NC3_open(const char * path, int ioflags,
* !_CRAYMPP, only pe 0 is valid
*/
if(basepe != 0) {
if(nc3) free(nc3);
if(nc3) {
free(nc3);
nc3 = NULL;
}
status = NC_EINVAL;
goto unwind_alloc;
}

View File

@ -13,7 +13,7 @@
* buffer of metadata information, i.e. the linked list of NC
* structs.
*
* @author Ed Hartnett
* @author Ed Hartnett, Dennis Heimbigner, Ward Fisher
*/
#include "config.h"
#include "nc4internal.h"
@ -935,12 +935,12 @@ nc4_check_dup_name(NC_GRP_INFO_T *grp, char *name)
*
* @return ::NC_NOERR No error.
* @return ::NC_ENOMEM Out of memory.
* @author Ed Hartnett
* @author Ed Hartnett, Ward Fisher
*/
int
nc4_type_new(NC_GRP_INFO_T *grp, size_t size, const char *name, int assignedid, NC_TYPE_INFO_T **type)
{
NC_TYPE_INFO_T *new_type;
NC_TYPE_INFO_T *new_type = NULL;
/* Allocate memory for the type */
if (!(new_type = calloc(1, sizeof(NC_TYPE_INFO_T))))
@ -950,8 +950,10 @@ nc4_type_new(NC_GRP_INFO_T *grp, size_t size, const char *name, int assignedid,
/* Remember info about this type. */
new_type->hdr.id = assignedid;
new_type->size = size;
if (!(new_type->hdr.name = strdup(name)))
if (!(new_type->hdr.name = strdup(name))) {
free(new_type);
return NC_ENOMEM;
}
new_type->hdr.hashkey = NC_hashmapkey(name,strlen(name));
@ -1333,16 +1335,18 @@ nc4_var_list_del(NC_GRP_INFO_T* grp, NC_VAR_INFO_T *var)
* @param dim Pointer to dim info struct of type to delete.
*
* @return ::NC_NOERR No error.
* @author Ed Hartnett
* @author Ed Hartnett, Ward Fisher
*/
int
nc4_dim_free(NC_DIM_INFO_T *dim)
{
/* Free memory allocated for names. */
if(dim) {
if (dim->hdr.name)
free(dim->hdr.name);
free(dim);
}
return NC_NOERR;
}

View File

@ -686,7 +686,7 @@ NC4_image_init(NC_HDF5_FILE_INFO_T* h5)
size_t min_incr = 65536; /* Minimum buffer increment */
double buf_prcnt = 0.1f; /* Percentage of buffer size to set
as increment */
size_t buf_size = h5->mem.memio.size;
size_t buf_size = 0;
void* buf_ptr = h5->mem.memio.memory;
unsigned flags = h5->mem.flags;

View File

@ -272,7 +272,8 @@ parsefilterspec(const char* optarg0, struct FilterSpec* spec)
}
/* Check for special cases */
if(strcmp(remainder,"none") == 0) {
if( (remainder == NULL) ||
(strncmp(remainder,"none",4) == 0)) {
spec->nofilter = 1;
goto done;
}
@ -741,7 +742,9 @@ copy_var_filter(int igrp, int varid, int ogrp, int o_varid)
VarID vid = {igrp,varid};
VarID ovid = {ogrp,o_varid};
/* handle filter parameters, copying from input, overriding with command-line options */
struct FilterSpec inspec, ospec, actualspec;
struct FilterSpec inspec = {NULL,0,0,0,NULL},
ospec = {NULL,0,0,0,NULL},
actualspec = {NULL,0,0,0,NULL};
int i;
char* ofqn = NULL;
int format, oformat;

View File

@ -198,7 +198,7 @@ genbin_defineglobalspecials(void)
static void
genbin_definespecialattributes(Symbol* var)
{
int stat;
int stat = NC_NOERR;
Specialdata* special = &var->var.special;
if(special->flags & _STORAGE_FLAG) {
int storage = special->_Storage;