Commit Graph

6691 Commits

Author SHA1 Message Date
Ward Fisher
804f29e3ac
Merge pull request #1443 from DennisHeimbigner/dispatchall.dmh
Remove netcdf-4 conditional on the dispatch table.
2019-07-22 14:22:21 -06:00
Dennis Heimbigner
4c92fc3405 Remove netcdf-4 conditional on the dispatch table.
Partially address: https://github.com/Unidata/netcdf-c/issues/1056

Currently, some of the entries in the dispatch table
are conditional'd on USE_NETCDF4.

As a step in upgrading the dispatch table for use
with user-defined tables, we remove that conditional.
This means that all dispatch tables must implement the
netcdf-4 specific functions even if only to make them
return NC_ENOTNC4. To simplify this, a set of default
functions are defined in libdispatch/dnotnc4.c to provide this
behavior. The file libdispatch/dnotnc3.c is also relevant to
this.

The primary fix is to modify the various dispatch tables to
remove the conditional and use the functions in
libdispatch/dnotnc4.c as appropriate. In practice, all of the
existing tables are prepared to handle this, so the only
real change is to remove the conditionals.

Misc. Unrelated fixes
1. Fix some annoying warnings in ncvalidator.

Notes:
1. This has not been tested with either pnetcdf or hdf4 enabled.
   When those are enabled, it is possible that there are still
   some conditionals that need to be fixed.
2019-07-20 13:59:40 -06:00
Ward Fisher
e747166f90
Merge pull request #1441 from NetCDF-World-Domination-Council/ejh_dispatch_ro
move the prototypes for NC_RO_, NC_NOTNC3_, and NC_NOTNC4_* functions to netcdf_dispatch.h
2019-07-19 14:41:21 -06:00
Ward Fisher
e4ca0287fd
Merge pull request #1440 from NetCDF-World-Domination-Council/ejh_nc4f_delete_grp_name
clean up freeing of libsrc4 metadata memory in HDF5 and HDF4
2019-07-19 14:41:05 -06:00
Ward Fisher
90d3386cc7
Merge pull request #1438 from DennisHeimbigner/nccopy-chunking.dmh
nccopy must use defaulting when there are no -c parameters
2019-07-18 15:08:20 -06:00
Dennis Heimbigner
4940cc34fc Update RELEASE_NOTES.md to include this fix 2019-07-18 11:15:07 -06:00
Dennis Heimbigner
764ea739b3 Merge branch 'master' into nccopy-chunking.dmh 2019-07-18 11:11:32 -06:00
Even Rouault
9d1331ddc9
tst_bug1442: improve test to retrieve a mix of valid values and values at fillvalue 2019-07-18 03:05:20 +02:00
Even Rouault
3f268203db
tst_bug1442.c: address review comments 2019-07-18 02:41:06 +02:00
Even Rouault
16babd3e89
nc_test4/Makefile.am: add tst_bug1442 2019-07-18 02:38:28 +02:00
Even Rouault
0c7be1d278
Add test case for bugfix of #1442 2019-07-18 02:23:43 +02:00
Ward Fisher
59c6aff529
Merge pull request #1437 from wkliao/erange_fill_configure
bug fix: respect configure option--enable-erange-fill
2019-07-17 17:25:48 -06:00
Even Rouault
77ffbce43b
NC4_get_vars(): fix out-of-bounds write with unlimited dimension
This fixes an issue hit by GDAL, and that is found in netcdf 4.6.3
and 4.7.0

git bisect pointed the problem to have started with

```
77ab979c5f is the first bad commit
commit 77ab979c5f
Author: Ed Hartnett <edwardjameshartnett@gmail.com>
Date:   Sat Jun 16 09:58:48 2018 -0600

    using get_vars but not put_vars

:040000 040000 8611e77aae fc9ffd1d13 M	libsrc4
```

where nc_get_vara_double() started using nc4_get_vars() underneath.

It turns out that nc4_get_vars() was buggy in the situation exercised by GDAL.

This can be reproduced with the following simple test case:

```

int main()
{
    int status;
    int cdfid = -1;
    int first_dim;
    int varid;
    int other_var;
    size_t anStart[NC_MAX_DIMS];
    size_t anCount[NC_MAX_DIMS];
    double* val = (double*)calloc(3, sizeof(double));

    status = nc_create("foo.nc", NC_NETCDF4, &cdfid);
    assert( status == NC_NOERR );

    status = nc_def_dim(cdfid, "unlimited_dim", NC_UNLIMITED, &first_dim);
    assert( status == NC_NOERR );

    status = nc_def_var(cdfid, "my_var", NC_DOUBLE, 1, &first_dim, &varid);
    assert( status == NC_NOERR );

    status = nc_def_var(cdfid, "other_var", NC_DOUBLE, 1, &first_dim, &other_var);
    assert( status == NC_NOERR );

    status = nc_enddef(cdfid);
    assert( status == NC_NOERR );

    /* Write 3 elements to set the size of the unlimited dim to 3 */
    anStart[0] = 0;
    anCount[0] = 3;
    status = nc_put_vara_double(cdfid, other_var, anStart, anCount, val);
    assert( status == NC_NOERR );

    /* Read 2 elements starting with index=1 */
    anStart[0] = 1;
    anCount[0] = 2;
    status = nc_get_vara_double(cdfid, varid, anStart, anCount, val);
    assert( status == NC_NOERR );

    status = nc_close(cdfid);
    assert( status == NC_NOERR );

    free(val);

    return 0;
}
```

Running it under Valgrind without this patch leads to
```
==19637==
==19637== Invalid write of size 8
==19637==    at 0x4C326CB: memcpy@@GLIBC_2.14 (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==19637==    by 0x4EDBE3D: NC4_get_vars (hdf5var.c:2131)
==19637==    by 0x4EDA24C: NC4_get_vara (hdf5var.c:1342)
==19637==    by 0x4E68878: NC_get_vara (dvarget.c:104)
==19637==    by 0x4E69FDB: nc_get_vara_double (dvarget.c:815)
==19637==    by 0x400C08: main (in /home/even/netcdf-c/build/test)
==19637==  Address 0xb70e3e8 is 8 bytes before a block of size 24 alloc'd
==19637==    at 0x4C2FB55: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==19637==    by 0x4009E8: main (in /home/even/netcdf-c/build/test)
==19637==
```
2019-07-18 01:25:21 +02:00
Ward Fisher
8b376e4992
Merge pull request #1439 from DennisHeimbigner/dap2-escapes.dmh
Fix encoding of a DAP2 constraint specified outside the URL.
2019-07-17 17:06:41 -06:00
Ed Hartnett
162685cd73 moved prototypes for NC_RO, NC_NOTNC3, and NC_NOTNC4 functions to netcdf_dispatch.h 2019-07-16 20:34:11 -06:00
Ed Hartnett
76d6b55eff moved call to nc4_rec_grp_del() to inside nc4_nc4f_list_del() 2019-07-16 16:29:06 -06:00
Ed Hartnett
4398cad8f5 whitespace cleanup 2019-07-16 16:17:07 -06:00
Ed Hartnett
b8e50c9254 moved freeing of allvars, alldims, alltypes lists to nc4_nc4f_list_del 2019-07-16 16:16:11 -06:00
Ed Hartnett
e9666f7333 moved free(h5) intonc4_nc4f_list_del 2019-07-16 16:07:21 -06:00
Ed Hartnett
d840c1864c removed unused prototype 2019-07-16 16:02:08 -06:00
Ed Hartnett
3310e67567 hdf4file.c cleanup 2019-07-16 14:54:42 -06:00
Ed Hartnett
bdf2711333 cleaned up handling of nc_file->dispatchdata in hdf4 file code 2019-07-16 14:48:26 -06:00
Dennis Heimbigner
000f22b12a Fix encoding of a DAP2 constraint specified outside the URL.
re: github issue #1425

The 'ncdump -v' command causes a constraint to be sent
to the opendap code (in libdap2). This is a separate path
from specifying the constraint via a URL.

This separate path encoded its constraint using code independent
of and duplicative of that provided by ncuri.c and this duplicate
code did not properly encode the constraint, which might include
square brackets.

Solution chosen here was to get rid of the duplicate code and
ensure that all URL escaping is performed in the ncuribuild function
in the ncuri.c file.

Also removed the use of the NEWESCAPE conditional in ncuri.c
because it is no longer needed.
2019-07-14 15:56:29 -06:00
Dennis Heimbigner
29281a2f89 nccopy must use defaulting when there are no -c parameters
re: issue https://github.com/Unidata/netcdf-c/issues/1436

It used to be that when no -c parameters were specified
(and the input was some variant of netcdf-3) that nccopy
let the netcdf-c library decide on any default chunking.
Now, it attempts to do it itself and is not doing it
correctly when unlimited dimensions are involved.

So fix is to revert to previous behavior.

Note: The chunking rules are getting too complicated; consider revising.
2019-07-14 15:18:03 -06:00
Wei-keng Liao
ed45a0a298 bug fix: respect configure option--enable-erange-fill when used at
configure command line.
2019-07-13 16:07:50 -05:00
Ward Fisher
9db0e26b80
Merge pull request #1432 from NetCDF-World-Domination-Council/ejh_dispatch
create header netcdf_dispatch.h
2019-07-09 12:58:28 -06:00
Ward Fisher
281ac5ff15
Merge pull request #1431 from NetCDF-World-Domination-Council/ejh_remove_macro
remove unused macro USE_REFCOUNT
2019-07-09 12:58:17 -06:00
Ward Fisher
c39de7bfc3
Merge pull request #1430 from NetCDF-World-Domination-Council/ejh_ncint
Fix memory problem in example sfc_pres_temp_more.c
2019-07-09 12:58:04 -06:00
Ward Fisher
8b1c4e3ff8
Merge pull request #1410 from Unidata/ansifix2.dmh
Fix ncconfigure.h to solve a -ansi problem with strdup()
2019-07-09 12:57:31 -06:00
Ward Fisher
0720a011c8
Merge pull request #1428 from NetCDF-World-Domination-Council/ejh_hdf4_docs
Fixing and expanding some documentation in the HDF4 code
2019-07-09 12:56:11 -06:00
Ed Hartnett
d408006d06 handle UDF formats on NC_create() 2019-07-05 13:39:50 -06:00
Ed Hartnett
d5816bb13e using netcdf_dispatch.h in tst_udf.c 2019-07-05 05:24:29 -06:00
Ed Hartnett
f5125a5b2e cleanup 2019-07-05 05:07:42 -06:00
Ed Hartnett
806ebc91b4 cleanup 2019-07-05 05:05:59 -06:00
Ed Hartnett
e6edc44439 cleanup 2019-07-05 05:04:07 -06:00
Ed Hartnett
72a000f4f9 moved dispatch table definition to netcdf_dispatch.h 2019-07-05 04:53:53 -06:00
Ed Hartnett
39ba4aae89 added netcdf_dispatch.h file 2019-07-05 04:50:36 -06:00
Ed Hartnett
cd79569e45 removed refcount from nc.h 2019-07-04 15:46:47 -06:00
Ed Hartnett
620f17d5ef finidhed removing refcount from dfile.c 2019-07-04 15:46:15 -06:00
Ed Hartnett
f6ea863011 finidhed removing refcount from dfile.c 2019-07-04 15:45:49 -06:00
Ed Hartnett
0727ccf5ad starting to take out ref count stuff 2019-07-04 15:45:03 -06:00
Ed Hartnett
edf1f92042 starting to take out ref count stuff 2019-07-04 15:44:01 -06:00
Ed Hartnett
085b59e0d2 comment 2019-07-04 13:47:14 -06:00
Ed Hartnett
0c069e8e4c fixed memory error in sfc_pres_temp_more.c 2019-07-04 13:46:33 -06:00
Ed Hartnett
bc09b7b8f5 documentation update 2019-07-04 10:23:11 -06:00
Ed Hartnett
758aac0634 documentation update 2019-07-04 10:22:13 -06:00
Ed Hartnett
cf0ab1c504 documentation update 2019-07-04 10:21:06 -06:00
Ed Hartnett
985ed35166 documentation update 2019-07-04 10:20:37 -06:00
Ed Hartnett
d7e46e8c5f documentation update 2019-07-04 10:16:21 -06:00
Ed Hartnett
9a7a7e28d1 documentation update 2019-07-04 10:15:32 -06:00