lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  PHC 
Open Source and information security mailing list archives
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Sat, 26 Jul 2014 19:35:22 -0700
From:	Mark D Rustad <>
To:	Rickard Strandqvist <>
Cc:	Neil Horman <>,
	Herbert Xu <>,
	"David S. Miller" <>,,
Subject: Re: [PATCH] crypto: rng.c:  Cleaning up missing null-terminate in conjunction with strncpy


On Jul 26, 2014, at 7:18 AM, Rickard Strandqvist <> wrote:

> Replacing strncpy with strlcpy to avoid strings that lacks null terminate.
> Signed-off-by: Rickard Strandqvist <>
> ---
> crypto/rng.c |    2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
> diff --git a/crypto/rng.c b/crypto/rng.c
> index e0a25c2..c3d4fb3 100644
> --- a/crypto/rng.c
> +++ b/crypto/rng.c
> @@ -65,7 +65,7 @@ static int crypto_rng_report(struct sk_buff *skb, struct crypto_alg *alg)
> {
> 	struct crypto_report_rng rrng;
> -	strncpy(rrng.type, "rng", sizeof(rrng.type));
> +	strlcpy(rrng.type, "rng", sizeof(rrng.type));
> 	rrng.seedsize = alg->cra_rng.seedsize;

Not to pick on this patch in particular, but you need to be careful about changing strncpy to strlcpy. Although strlcpy ensures termination, it does not prevent information leakage - strncpy ensures that the entire destination buffer is written. When leakage is a concern, it is better to use strncpy and then to store a zero in the last location of the buffer to ensure termination.

These "simple" transformations can be risky - and many of these do not represent any sort of problem when the source is smaller than the destination. I hope information leakage is being considered.

Mark Rustad,

Download attachment "signature.asc" of type "application/pgp-signature" (842 bytes)

Powered by blists - more mailing lists