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

Possibly bad logic in evalfunction.c:FnCallSelectServers

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Done
    • Priority: High
    • Resolution: Fixed
    • Affects Version/s: 3.18.0
    • Fix Version/s: 3.18.0
    • Component/s: cf-agent
    • Labels:
    • Story Points:
      0

      Description

      In evalfunction.c:FnCallSelectServers I believe there is something wrong with the logic.

      The following piece of code will assign a nullbyte to recvbuf[-1] if there is no message in the socket.

       

      char recvbuf[CF_BUFSIZE];
      ssize_t n_read = recv(sd, recvbuf, maxbytes, 0);
      
      if (n_read < 0)
      {
          /* maxbytes was checked earlier, but just make sure... */
          assert((size_t) n_read < sizeof(recvbuf));
          recvbuf[n_read] = '\0';
      

       

      I believe the condition in the if statement should be (n_read >= 0) in stead of (n_read < 0)

       This seems to only affect 3.18. In 3.15 and 3.12 the condition is (n_read != -1)

       

        Attachments

          Activity

            People

            • Assignee:
              larsewi Lars Erik Wik
              Reporter:
              larsewi Lars Erik Wik
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Summary Panel