lists.openwall.net   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  linux-cve-announce  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:	Tue, 17 Nov 2009 12:25:03 +0000
From:	Pádraig Brady <P@...igBrady.com>
To:	Roel Kluin <roel.kluin@...il.com>
CC:	Randy Dunlap <rdunlap@...otime.net>, linux-doc@...r.kernel.org,
	Andrew Morton <akpm@...ux-foundation.org>,
	LKML <linux-kernel@...r.kernel.org>,
	David Wagner <daw@...berkeley.edu>
Subject: Re: [PATCH] Documentation: Fix NUL termination of strncpy

Roel Kluin wrote:
> Ensure the copied strings are NUL terminated.
> 
> Signed-off-by: Roel Kluin <roel.kluin@...il.com>
> ---
>> Rationale (please correct me if I'm wrong):
> 
> diff --git a/Documentation/accounting/getdelays.c b/Documentation/accounting/getdelays.c
> index 6e25c26..4d71b0e 100644
> --- a/Documentation/accounting/getdelays.c
> +++ b/Documentation/accounting/getdelays.c
> @@ -303,7 +303,7 @@ int main(int argc, char *argv[])
>  				err(1, "Invalid rcv buf size\n");
>  			break;
>  		case 'm':
> -			strncpy(cpumask, optarg, sizeof(cpumask));
> +			strncpy(cpumask, optarg, sizeof(cpumask) - 1);

You need to explicitly NUL terminate strncpy():
http://www.pixelbeat.org/programming/gcc/string_buffers.html

cheers,
Pádraig.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ