Uploaded image for project: 'C Driver'
  1. C Driver
  2. CDRIVER-1900

Coverity analysis defect 76404: Out-of-bounds write

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • 1.5.0
    • None
    • None
    • None

    Description

      Out-of-bounds write to a buffer

      Defect 76404 (STATIC_C)
      Checker OVERRUN (subcategory write)
      File: /src/libbson/examples/bson-streaming-reader.c
      Function main
      /src/libbson/examples/bson-streaming-reader.c, line: 160
      Calling allocating function "malloc" which allocated memory dictated by argument "strlen(optarg)".

                   hostname = (char *)malloc (strlen (optarg));

      /src/libbson/examples/bson-streaming-reader.c, line: 160
      Assigning: "hostname" = "malloc(strlen(optarg))".

                   hostname = (char *)malloc (strlen (optarg));

      /src/libbson/examples/bson-streaming-reader.c, line: 161
      strcpy, whose first argument "hostname" has length equal to strlen of its second argument "optarg", will overrun its first argument because of the terminating null.

                   strcpy (hostname, optarg);

      Attachments

        Activity

          People

            jesse@mongodb.com A. Jesse Jiryu Davis
            xgen-internal-coverity Coverity Collector User
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: