Skip to content
Commit 69051874 authored by Alessandro Ghedini's avatar Alessandro Ghedini Committed by Emilia Kasper
Browse files

Make BUF_strndup() read-safe on arbitrary inputs



BUF_strndup was calling strlen through BUF_strlcpy, and ended up reading
past the input if the input was not a C string.

Make it explicitly part of BUF_strndup's contract to never read more
than |siz| input bytes. This augments the standard strndup contract to
be safer.

The commit also adds a check for siz overflow and some brief documentation
for BUF_strndup().

Reviewed-by: default avatarMatt Caswell <matt@openssl.org>
(cherry picked from commit 110f7b37)
(cherry picked from commit f61216ba)
parent 9d1fcbeb
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment