Coder Social home page Coder Social logo

Comments (2)

mauzey1 avatar mauzey1 commented on June 25, 2024

I have identified where in CMOR this segfault is happening. Below is a section of cmor_CV_checkFurtherInfoURL that checks if the URL template has tokens separated by '<' and '>' characters.

cmor/Src/cmor_CV.c

Lines 379 to 385 in 8d45339

/* -------------------------------------------------------------------- */
/* If this is a string with no token we have nothing to do. */
/* -------------------------------------------------------------------- */
szToken = strtok(szFurtherInfoURLTemplate, "<>");
if (strcmp(szToken, cmor_current_dataset.furtherinfourl) == 0) {
return (0);
}

When passing an emtpy string to strtok, it will assign a null to szToken. This will cause strcmp to segfault when comparing szToken.

This lead to discovering another behavior of this function: Using the further info URL of the current dataset as a template.

cmor/Src/cmor_CV.c

Lines 373 to 377 in 8d45339

/* -------------------------------------------------------------------- */
/* Retrieve default Further URL info */
/* -------------------------------------------------------------------- */
strncpy(szFurtherInfoURLTemplate, cmor_current_dataset.furtherinfourl,
CMOR_MAX_STRING);

If you were to have the following value in your user input...

"further_info_url":       "https://furtherinfo.es-doc.org/<mip_era><source_id>"

then the function will treat that as a template to be turned into a URL for comparison.

It will then proceed to compare what is provided by the user input with the URL created from the template.

C Traceback:
In function: 

!!!!!!!!!!!!!!!!!!!!!!!!!
!
! Warning: The further info in attribute does not match the one found in your Control Vocabulary(CV) File. 
! We found "https://furtherinfo.es-doc.org/<mip_era><source_id>" and 
! CV requires "https://furtherinfo.es-doc.org/CMIP6.PCMDI-test-1-0" 
! Check your Control Vocabulary file "Tables/CMIP6_CV.json".
! 
!
!!!!!!!!!!!!!!!!!!!!!!!!!

So any string that begins with "https://furtherinfo.es-doc.org/" will be valid input according to the CV's further_info_url value, but not if they contain any of the template tokens such as the ones in cmor.h

#define CMOR_DEFAULT_FURTHERURL_TEMPLATE "https://furtherinfo.es-doc.org/<mip_era><institution_id><source_id><experiment_id><sub_experiment_id><variant_label>"

from cmor.

durack1 avatar durack1 commented on June 25, 2024

@mauzey1 it would be great to catch this segfault, and rather issue an error message suggesting changes required to the user and quit, does that seems reasonable?

from cmor.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.