[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[netCDF #OBE-822161]: Missing bounds check in NetCDF4-C++: NcVar::getDim()



Hello,

I've opened an issue on GitHub for this problem which you can view here:

* https://github.com/Unidata/netcdf-cxx4/issues/26

Thanks for the bug report; I will get this fix in for the upcoming release!

-Ward

> I believe that NcVar::getDim() is not bounds checking its input parameter.
> See below.
> 
> Thanks,
> -- Elizabeth
> 
> I'm causing malloc() problems with the following code:
> 
> for (int k=0; k<RANK; ++k) {
> printf("    DD3.1 %ld %d\n", ncvar.getDimCount(), k);
> ...
> netCDF::NcDim dim(ncvar.getDim(k));
> 
> }
> 
> This creates the output:
> 
> DD3.1 2 0
> DD3.2
> DD3.3
> DD3.4
> DD3.1 2 1
> DD3.2
> DD3.3
> DD3.4
> DD3.1 2 2
> 
> 
> test_grid(86063,0x7fff729ac310) malloc: *** error for object
> 0x7fd38053bdf8: pointer being freed was not allocated
> 
> *** set a breakpoint in malloc_error_break to debug
> 
> 

Ticket Details
===================
Ticket ID: OBE-822161
Department: Support netCDF
Priority: Normal
Status: Closed