Commit Graph

224 Commits

Author SHA1 Message Date
Ed Hartnett
06eb8669df applied gsjaardema's suggested change to ocnode.c 2017-11-30 09:22:14 -07:00
Ed Hartnett
0fbfc2bce4 more warnings 2017-11-30 09:16:29 -07:00
Ed Hartnett
3c5404ccf7
Merge branch 'master' into ejh_ncfunc_testing 2017-11-28 00:04:38 +00:00
Ward Fisher
7796ecb196
Merge branch 'master' into vc9 2017-11-27 15:03:02 -07:00
Nehal J Wani
1b91bd89d4
Fix build on pre-C99 compilers
- Make sure that the variables are declared at the top of the block.
 - Add fix to enable inline for various compilers
2017-11-26 01:47:54 +05:30
Dennis Heimbigner
4db4393e69 Begin changing over to use strlcat instead of strncat because
strlcat provides better protection against buffer overflows.

Code is taken from the FreeBSD project source code. Specifically:
https://github.com/freebsd/freebsd/blob/master/lib/libc/string/strlcat.c
License appears to be acceptable, but needs to be checked by e.g. Debian.

Step 1:
1. Add to netcdf-c/include/ncconfigure.h to use our version
   if not already available as determined by HAVE_STRLCAT in config.h.
2. Add the strlcat code to libdispatch/dstring.c
3. Turns out that strlcat was already defined in several places.
   So remove it from:
	ncgen3/genlib.c
	ncdump/dumplib.c
3. Define strlcat extern definition in ncconfigure.h.
4. Modify following directories to use strlcat:
	libdap2 libdap4 ncdap_test dap4_test
   Will do others in subsequent steps.
2017-11-23 10:55:24 -07:00
Ed Hartnett
7e662c6b87 fixed easy warnings 2017-11-20 05:55:04 -07:00
Ward Fisher
3c8dcc8c94 Removed dangling reference to old file. 2017-11-03 16:07:39 -06:00
Ward Fisher
bb2505cf4e
Merge branch 'master' into newrc.dmh 2017-11-03 14:57:27 -06:00
Ward Fisher
967334041e Merge remote-tracking branch 'origin/urlparams.dmh' into merge_dennis_pr 2017-11-02 14:27:37 -06:00
Dennis Heimbigner
4430a7d1a9 Fix https://github.com/Unidata/netcdf-c/issues/569
Serious bad on my part. For some reason, I changed the set of
characters allowed n a DAP name. In particular, characters that
are legal according to the DAP spec were removed. So when one of
this removed characters was encountered, it produced a parse
error.

In this case, the offending character was a single quote character in the name:
Blackadar's_mixing_length_scale_hybrid

The reason it worked for java is because the escape character set
is correct and different than the one in the netcdf-c dap code.
2017-11-02 13:04:03 -06:00
Dennis Heimbigner
354f63ab42 Make work with cmake 2017-11-01 21:53:21 -06:00
Dennis Heimbigner
f827cf13f2 As a result of changes I made to
url parameter handling, the parameter
lookup code was ignoring parameters
because I was giving it a url stripped
of parameters instead of the one with
parameters.

This code change fixes the parameter processing
so it again used the correct url.

reference:
docs/OPeNDAP.dox#section Defined Client Parameters
2017-11-01 19:48:51 -06:00
Dennis Heimbigner
9935d54fdf Merge master and resolve conflicts 2017-10-28 13:57:23 -06:00
Ward Fisher
67018ecabb Merge branch 'v4.5.0-release-branch' into netrc.dmh 2017-09-25 13:46:32 -06:00
Dennis Heimbigner
d1e17b5ee7 re: pull request: https://github.com/Unidata/netcdf-c/issues/487
The use of the following version-specific curl flags
is not always properly wrapped or aliased using
config.h HAVE_CURL... ifdefs.
# CURLOPT_USERNAME is not defined until curl version 7.19.1
# CURLOPT_PASSWORD is not defined until curl version 7.19.1
# CURLOPT_KEYPASSWD is not defined until curl version 7.16.4
  -- aliased as needed to CURLOPT_SSLKEYPASSWD
# CURLINFO_RESPONSE_CODE is not defined until curl version 7.10.7
  -- aliased as needed to CURLINFO_HTTP_CODE
# CURLOPT_CHUNK_BGN_FUNCTION is not defined until curl version 7.21.0
  -- not used in our code
2017-09-18 16:44:31 -06:00
Dennis Heimbigner
b7f6941da8 It is imperative that this fix goes into
v4.5-release-candidate branch and master branch ASAP.

The bug occurs in d4rc.c where strcmp is being applied to NULL.
Also, the code in which it occurs is debugging code, so it needs
to be #ifdef'd.  This fix may cause minor conflicts with other
outstanding pull requests that fix the same bug. But the
conflicts should be minor and easy to resolve.
2017-09-08 13:54:02 -06:00
Dennis Heimbigner
ad32350355 Oops. Forgot to convert over libdap4 use of NC_mktmp
and NC_readfile and NC_combinehostport.
2017-09-03 15:09:10 -06:00
Dennis Heimbigner
a2e0f069ec This pr should probably be delayed until after Version 4.5.
Primary change is to cleanup code and remove duplicated code.

1. Unify the rc file reading into libdispatch/drc.c. Eventually extend
   if we need rc file for netcdf itself as opposed to the dap code.
2. Unify the extraction from the rc file of DAP authorization info.
3. Misc. other small unifications: make temp file, read file.
4. Avoid use of libcurl when reading file:// because
   there is some kind of problem with the Visual Studio version.
   Might be related to the winpath problem.
   In any case, do direct read instead.
5. Add new error code NC_ERCFILE for errors in reading RC file.
6. Complete documentation cleanup as indicated in this comment
   https://github.com/Unidata/netcdf-c/pull/472#issuecomment-325926426
7. Convert some occurrences of #ifdef _WIN32 to #ifdef _MSC_VER
2017-09-02 18:09:36 -06:00
Dennis Heimbigner
3a99220789 Make branch compile under cmake 2017-08-31 15:32:41 -06:00
Dennis Heimbigner
8e2abdeed8 Initial version 2017-08-31 14:19:56 -06:00
Dennis Heimbigner
61d2b38c8e Final fixes 2017-08-30 19:13:52 -06:00
Dennis Heimbigner
7c592cfb2a 1. Unify the rc file reading into libdispatch/drc.c. Eventually extend
if we need rc file for netcdf itself as opposed to the dap code.
2017-08-30 17:44:57 -06:00
Dennis Heimbigner
15db0f15ea Clarify rc documentation 2017-08-30 12:05:04 -06:00
Dennis Heimbigner
80dbc7fb6c Undo DECODE_IDENTIFIER change 2017-08-29 18:01:26 -06:00
Dennis Heimbigner
bc9e41ae2b 1. Fix bug in ocrc.c#combinecredentials where a null user+pwd
generates garbage. This in turn interferes with using .netrc
because the garbage user+pwd can will override the
.netrc. Note that this may work ok sometimes
if the garbage happens to start with a nul character.

2. It turns out that the user:pwd combination needs to support
character escaping. One reason is the user may contain an '@' character.
The other is that modern password rules make it not unlikely that
the password will contain characters that interfere with url parsing.
So, the rule I have implemented is that all occurrences of the user:pwd
format must escape any dodgy characters. The escape format is URL escaping
of the form %XX. This applies both to user:pwd
embedded in a URL as well as the use of HTTP.CREDENTIALS.USERPASSWORD
in a .dodsrc/.daprc file. The user and password in .netrc must not
be escaped. This is now documented in docs/auth.md

The fix for #2 actually obviated #1. Now, internally, the user and pwd
are stored separately and not in the user:pwd format. They are combined
(and escaped) only when needed.
2017-08-29 14:11:15 -06:00
Dennis Heimbigner
442f4d9bc9 Fix bug in ocrc.c#combinecredentials
where a null user+pwd generates
garbage. This in turn interferes
with using .netrc because the garbage
user+pwd can (sometimes) override
the .netrc.
Not entirely sure what is going on
because it works as is under e.g. cygwin.
In any case it needs fixing.
2017-08-25 14:42:22 -06:00
Ward Fisher
9e7a902dcf Merge branch 'issue435.dmh' into multi-pull 2017-07-27 12:20:11 -06:00
Dennis Heimbigner
5e96b0c42e Force binary mode in oc2/ocread.c 2017-07-18 12:44:39 -06:00
Dennis Heimbigner
715a6fe5eb The files libdispatch/dwinpath.c and include/ncwinpath.h
were added to provide a path name converter from e.g. cygwin
paths to e.g. windows paths. This is necessary because
the shell scripts may produce cygwin paths, but the code
may have been compiled with Visual Studio. Similar issues
arise with Mingw.

At appropriate places, and if using Visual Studio or Mingw,
I added calls to the path conversion code.
Apparently I forgot to find all the places where this
conversion was needed. So this pr does the following:
1. Push the calls to the converter to the various libXXX
   directories and out of libdispatch/dfile.c.
2. Add conversion calls to other parts of the code like oc2.

I also turns out that conversion code in dapcvt.c
had a bug when handling DAP Byte type under visual studio.

Notes:
1. there may still be places I missed that need to do path conversion.
2. need to make sure that calls to e.g. H5open also use converted path.
2017-07-13 10:40:07 -06:00
Dennis Heimbigner
9719fbfbad re: hithub issue https://github.com/Unidata/netcdf-c/issues/435
Some temporary files are being left in a tempdir (e.g. /tmp
under *nix*).

The situation is described tersely in
netcdf-c/docs/auth.html#REDIR Basically, when a url is used that
requires redirection, a physical cookiejar file is required
to exist in the file system in order for this to work.

Since it was difficult to figure out when redirection was
being used (it was internal to libcurl) I needed to be prepared for that
eventuality. The result was that I always created a cookiejar file if one
was not specified in the rc file. This actually occurs in two places:
one inside oc2 and one inside libdap4.

The solution was two-fold:
1. do not use a cookiejar directory -- create cookiejar file directly
2. ensure that all cookiejar related files are reclaimed by nc_close().
Note that if nc_close (or nc_abort) is not called for whatever reason,
then reclamation will not occur.
2017-07-05 10:03:48 -06:00
Dennis Heimbigner
dc9e31df68 Fix for github issue https://github.com/Unidata/netcdf-c/issues/310.
The problem was that for opendap, it is possible to use keywords
as identifiers
 when there is no ambiguity. However, the DAP2
parser lost the case of the identifier used the lower case version.
Fix is to use the actual text of the symbol when it is used as an identifier.
Also added a test case for this (kwcase.*).

Additionally cleaned up some misc. dap2 testing problems.
1. ncdap_test/tst_ncdap3.sh was using an empty test set.
   restored the testing of datasets.
2. as a consequence of #1, some tests needed to be updated with minor
   tweeks.
3. fix dapmerge to handle multiple DODS_EXTRAS attributes.
4. modify buildattribute to suppress nul characters and terminate
   the name at the first nul.
5. clean up various test scripts to remove residual, unused
   references to obsolete netcdf-4 translation.
6. export e.g. NCDUMP from test_common.in so that non-top-level
   shell scripts can access it.
2017-06-28 13:51:01 -06:00
Dennis Heimbigner
6d8809100f Fix pull request https://github.com/Unidata/netcdf-c/pull/374 (dap4.dmh)
1. When running under windows (as opposed to cygwin)
   we need to make sure to not user /cygdrive/ file paths.
   This was ocurring in libdap4/d4read.c, but may occur
   elsewhere.
2. Shell scripts in the git repo are not being checked-out
   with the executable mode set. Had core.filemode set to false.
   Was a major hassle to fix.
2017-04-03 21:39:44 -06:00
Dennis Heimbigner
031ae14842 upgrade new oc files to nclist/ncbytes 2017-03-17 17:20:02 -06:00
Dennis Heimbigner
be6e1b65dc Fix conflicts with master 2017-03-17 14:58:38 -06:00
Dennis Heimbigner
3213705205 Re: github issue https://github.com/Unidata/netcdf-c/issues/373
Github issue https://github.com/Unidata/netcdf-c/issues/152
requested that "orphaned" DAS attributes be included in the netcdf
metadata as global variables. The term orphaned here meant that
they were not connected to any variable in the DDS.
This was done in pull request https://github.com/Unidata/netcdf-c/pull/164

However, some servers (e.g. Thredds) include attributes for variables not
specified in a constraint expression, but which exist in the full DDS.
So I was adding these to the set of global attributes, but in retrospect
this should not have been done: they should have been elided.

Solution: modify oc2 code to be more distriminatory about
which orphaned attributes to include.
2017-03-11 16:17:20 -07:00
Dennis Heimbigner
1aab7556cf ckp 2017-03-11 15:20:20 -07:00
Dennis Heimbigner
3db4f013bf Primary change: add dap4 support
Specific changes:
1. Add dap4 code: libdap4 and dap4_test.
   Note that until the d4ts server problem is solved, dap4 is turned off.
2. Modify various files to support dap4 flags:
	configure.ac, Makefile.am, CMakeLists.txt, etc.
3. Add nc_test/test_common.sh. This centralizes
   the handling of the locations of various
   things in the build tree: e.g. where is
   ncgen.exe located. See nc_test/test_common.sh
   for details.
4. Modify .sh files to use test_common.sh
5. Obsolete separate oc2 by moving it to be part of
   netcdf-c. This means replacing code with netcdf-c
   equivalents.
5. Add --with-testserver to configure.ac to allow
   override of the servers to be used for --enable-dap-remote-tests.
6. There were multiple versions of nctypealignment code. Try to
   centralize in libdispatch/doffset.c and include/ncoffsets.h
7. Add a unit test for the ncuri code because of its complexity.
8. Move the findserver code out of libdispatch and into
   a separate, self contained program in ncdap_test and dap4_test.
9. Move the dispatch header files (nc{3,4}dispatch.h) to
   .../include because they are now shared by modules.
10. Revamp the handling of TOPSRCDIR and TOPBUILDDIR for shell scripts.
11. Make use of MREMAP if available
12. Misc. minor changes e.g.
	- #include <config.h> -> #include "config.h"
	- Add some no-install headers to /include
	- extern -> EXTERNL and vice versa as needed
	- misc header cleanup
	- clean up checking for misc. unix vs microsoft functions
13. Change copyright decls in some files to point to LICENSE file.
14. Add notes to RELEASENOTES.md
2017-03-08 17:01:10 -07:00
Dennis Heimbigner
e2967bb622 Fix for Github issue 314.
Problem was in oc2/dap.y.
In definition of errormsg:, change WORD_WORD to WORD_STRING
since the msg field of an opendap error response is a quoted
string.

Also took the opportunity to modify ncgen to
transfer the logging level (-L flag) into the c-code
generated using -lc.
2016-09-01 22:06:07 -06:00
Ward Fisher
ad201da5f1 Addressed coverity issue 1256385, potential resource leak. 2016-07-06 15:06:06 -06:00
Ward Fisher
d8e86219b5 Corrected coverity issue 1264401, buffer not null terminated. 2016-07-06 14:49:15 -06:00
Ward Fisher
78b43dbfdb Addressed a memory leak identified by Coverity. See Coverity #1256386 2016-03-11 11:03:01 -07:00
Ward Fisher
f12daedeb3 Corrected a coverity issue with a potential negative argument. Coverity 711780 2016-03-08 13:48:30 -07:00
Robert T. McGibbon
3303ccd519 Fix preprocessor for mingw 2015-12-07 18:08:13 -08:00
dmh
cbb6df3232 Github issue 152: https://github.com/Unidata/netcdf-c/issues/152
User request to have all orphaned DAP2 attributes kept as netcdf
global attributes. This is primarily a change in the oc code
nplus testcase dataset changes.

Result may be inconsistent with netcdf-Java output.
2015-11-29 20:38:12 -07:00
Bas Couwenberg
b8e4161baf Fix inconsistent return type. 2015-11-10 00:19:33 +01:00
Ward Fisher
612b35a84c Merge branch 'master' into cdf-5, in preparation for merging the CDF-5 functionality into the master branch. This will be the key new feature for netcdf 4.4.0. 2015-11-05 13:40:35 -07:00
dmh
7480d7d97d - clean up the dfile.c confusion about NC_64_BIT_OFFSET
- sync oc2 with  master for https://DennisHeimbigner@github.com/Unidata/oc.git
- Cleanup auth.html documentation.
- Cleanup obsolete documentation.
2015-10-24 21:45:13 -06:00
dmh
0f59785f37 sync with base oc library 2015-10-22 15:34:56 -06:00
dmh
a5c8f7c7e3 synch with base oc 2015-10-21 14:53:30 -06:00