[netcdfgroup] NetCDF 4.1.2 and 4.1.3 bug report (nc_put_varm_type with stride=NULL causes a segfault)

Hello,

It seems to me that there is a bug in int NCDEFAULT_put_varm(...)
(located in libdispatch/var.c around line 515).

According the the C API manual, stride = NULL is an acceptable
argument interpreted as (1, 1, 1, ...).

Looking that at around line 611


      /*
       * Verify stride argument.
       */
      if(stride != NULL)
         stride1 = 1;
         for (idim = 0; idim <= maxidim; ++idim)
         {
            if ((stride[idim] == 0)
                /* cast needed for braindead systems with signed size_t */
                || ((unsigned long) stride[idim] >= X_INT_MAX))
            {
               return NC_ESTRIDE;
            }
            if(stride[idim] != 1) stride1 = 0;
         }


note that the if-clause seems to be missing { and }. As it stands, the
for-loop is executed even if stride==NULL, causing a segfault at "if
((stride[idim] == 0)" (line 615).

Thanks!

-- 
Constantine



  • 2011 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdfgroup archives: