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

Re: [lvm-devel] [PATCH] Missing error checking in cmirrord



On 06/18/2010 11:10 PM, Jonathan Brassow wrote:
> There are missing error checks... it's possible for
> sprintf to fail.
> 
>  brassow
> 
> Index: LVM2/daemons/cmirrord/functions.c
> ===================================================================
> --- LVM2.orig/daemons/cmirrord/functions.c
> +++ LVM2/daemons/cmirrord/functions.c
> @@ -1371,15 +1371,21 @@ static int clog_get_sync_count(struct dm
>  
>  static int core_status_info(struct log_c *lc __attribute((unused)), struct dm_ulog_request *rq)
>  {
> +	int r;
>  	char *data = (char *)rq->data;
>  
> -	rq->data_size = sprintf(data, "1 clustered-core");

	rq->data_size = 0;

> +	r = sprintf(data, "1 clustered-core");
> +	if (r < 0)
> +		return r;
> +
> +	rq->data_size = r;

	rq->data_size = r + 1;

sprintf does not count trailing \0 ... (and this is probably part of
the mysterious fails of cmirrord).

 
Milan


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