Re: [PATCH] Documentation: Fix NUL termination of strncpy

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Roel Kluin wrote:
> Ensure the copied strings are NUL terminated.
> 
> Signed-off-by: Roel Kluin <roel.kluin@xxxxxxxxx>
> ---
>> 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-doc" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux