Uploaded image for project: 'MariaDB MaxScale'
  1. MariaDB MaxScale
  2. MXS-348

Incorrect use of strncat

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.1.1, 1.2.0, 1.3.0, 1.4.0
    • Fix Version/s: 2.1.0
    • Component/s: Core
    • Labels:
      None
    • Environment:
      All
    • Sprint:
      2016-12, 2016-13, 2016-15

      Description

      The function strncat is used 29 times at present, and appears to be subject to a widespread misunderstanding. The function does NOT limit the length of the result to the value of the final parameter. It limits the number of characters added to the value of the final parameter. So, a safe use of strncat would be:
      strncat(str1, str2, sizeof(str1) - sizeof(str2) - 1);
      I am not recommending that exact construction, simply giving it as an illustration of correct use of the size limit in strncat.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              johan.wikman Johan Wikman
              Reporter:
              martin brampton martin brampton (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: