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

Coverity analysis defect 76404: Out-of-bounds write

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 1.5.0
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None

      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);
      

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

              Created:
              Updated:
              Resolved: