Uploaded image for project: 'CFEngine Community'
  1. CFEngine Community
  2. CFE-3672

Cf-promises segfault when parsing methods promise in common bundle

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Done
    • Priority: (None)
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.18.0
    • Component/s: cf-promises
    • Labels:
      None
    • Story Points:
      0

      Description

      While mistakenly putting a methods promise in a common bundle and running cf-promises on it i produced a segfault.

      bundle common segv
      {
        methods:
            "some" usebundle => reporter("123");
      }
      
      bundle agent reporter(x)
      {
        reports:
            "${x}";
      }
      

      After debugging i traced the problem in these two lines PromiseTypeSyntaxGet returns null when passed the "methods" promise type and the for loop bellow segfaults.

      GDB STACKTRACE:

      (gdb) backtrace
      #0  0x00007ffff7ec8141 in ConstraintCheckSyntax (constraint=0x5555555afff0, 
          errors=0x5555555aeb20) at policy.c:587
      #1  0x00007ffff7ecd844 in PromiseCheck (pp=0x5555555afdd0, errors=0x5555555aeb20)
          at policy.c:2801
      #2  0x00007ffff7ec8553 in PolicyCheckPromiseType (section=0x5555555afce0, 
          errors=0x5555555aeb20) at policy.c:670
      #3  0x00007ffff7ec85dd in PolicyCheckBundleSections (sections=0x5555555afba0, 
          errors=0x5555555aeb20) at policy.c:685
      #4  0x00007ffff7ec86b0 in PolicyCheckBundle (bundle=0x5555555afab0, 
          errors=0x5555555aeb20) at policy.c:707
      #5  0x00007ffff7ec98c1 in PolicyCheckPartial (policy=0x5555555aa050, 
          errors=0x5555555aeb20) at policy.c:1134
      #6  0x00007ffff7eb9c3b in LoadPolicyFile (ctx=0x55555555c400, 
          config=0x55555555c2d0, policy_file=0x55555555c3c0 "segfault.cf", 
          policy_files_hashes=0x5555555a9d20, parsed_files_checksums=0x5555555a9e80, 
          failed_files=0x5555555a9fe0) at loading.c:352
      #7  0x00007ffff7eba2fb in LoadPolicy (ctx=0x55555555c400, config=0x55555555c2d0)
          at loading.c:503
      #8  0x00005555555564d4 in main (argc=2, argv=0x7fffffffdd68) at cf-promises.c:139
      (gdb) frame 0
      #0  0x00007ffff7ec8141 in ConstraintCheckSyntax (constraint=0x5555555afff0, 
          errors=0x5555555aeb20) at policy.c:587
      587         for (size_t i = 0; promise_type_syntax->constraints[i].lval != NULL; i++)
      (gdb) l
      582         const BundleSection *section = constraint->parent.promise->parent_section;
      583         const Bundle *bundle = section->parent_bundle;
      584
      585         /* Check if lvalue is valid for the bundle's specific section. */
      586         const PromiseTypeSyntax *promise_type_syntax = PromiseTypeSyntaxGet(bundle->type, section->promise_type);
      587         for (size_t i = 0; promise_type_syntax->constraints[i].lval != NULL; i++)
      588         {
      589             const ConstraintSyntax *body_syntax = &promise_type_syntax->constraints[i];
      590             if (strcmp(body_syntax->lval, constraint->lval) == 0)
      591             {
      (gdb) 

        Attachments

          Activity

            People

            Assignee:
            Alias Georgios Kotzampopoulos
            Reporter:
            Alias Georgios Kotzampopoulos
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: