-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: 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);