[sheepdog] [PATCH 2/2] object cache: add lock helpers to clarify the lock order

MORITA Kazutaka morita.kazutaka at gmail.com
Sat Jan 26 10:24:41 CET 2013


At Fri, 25 Jan 2013 22:14:19 +0800,
Liu Yuan wrote:
> @@ -591,18 +631,16 @@ static void reclaim_done(struct work *work)
>  static int create_dir_for(uint32_t vid)
>  {
>  	int ret = 0;
> -	struct strbuf buf = STRBUF_INIT;
> +	char p[PATH_MAX];
>  
> -	strbuf_addstr(&buf, object_cache_dir);
> -	strbuf_addf(&buf, "/%06"PRIx32, vid);
> -	if (mkdir(buf.buf, def_dmode) < 0)
> +	sprintf(p, "%s/%06"PRIx32, object_cache_dir, vid);

Use snprintf to avoid buffer overflow.

Thanks,

Kazutaka



More information about the sheepdog mailing list