Commit 5225af18 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

NetCDF zero length number attributes cause null-pointer dereference [Bug: #8589].

parent adc474bb
......@@ -921,11 +921,9 @@ void cdf_set_cdi_attr(int ncid, int ncvarid, int attnum, int cdiID, int varID)
}
else if ( xtypeIsText(atttype) )
{
char attstring[256];
char *pattstring = attlen > sizeof(attstring) ? (char*) malloc(attlen*sizeof(char)) : attstring;
cdfGetAttText(ncid, ncvarid, attname, attlen, pattstring);
cdiDefAttTxt(cdiID, varID, attname, (int)attlen, pattstring);
if (attlen > sizeof(attstring)) free(pattstring);
char attstring[8192];
cdfGetAttText(ncid, ncvarid, attname, sizeof(attstring), attstring);
cdiDefAttTxt(cdiID, varID, attname, (int)attlen, attstring);
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment