Coverity analysis defect 76404: Out-of-bounds write

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Done
    • Priority: Major - P3
    • 1.5.0
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • 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:
              A. Jesse Jiryu Davis
              Reporter:
              Coverity Collector User
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved: