----- Original Message -----
From: "Jan Safranek" <jsafr...@redhat.com>
To: "Ivana Hutarova Varekova" <varek...@redhat.com>
Cc: libcg-devel@lists.sourceforge.net
Sent: Wednesday, June 13, 2012 3:57:54 PM
Subject: Re: [Libcg-devel] [PATCH 1/2] api: cg_build_path - do not add needless 
"/"

On 06/05/2012 12:19 PM, Ivana Hutarova Varekova wrote:
> cg_build_path adds needless "/" character in cases when / the input path
useless '/'?                                             ^^^

> ends/starts with character "/" itself. This character is added now only in
> cases it is waned and it was not set.
wanted?        ^^^
Sorry for these two typos, I will repost the patch without them.

> 
> Signed-off-by: Ivana Hutarova Varekova <varek...@redhat.com>
> ---
> 
>  0 files changed, 0 insertions(+), 0 deletions(-)
> 
> diff --git a/src/api.c b/src/api.c
> index 29de777..aab05e2 100644
> --- a/src/api.c
> +++ b/src/api.c
> @@ -1124,9 +1124,15 @@ static char *cg_build_path_locked(const char *name, 
> char *path,
>                               tmp = strdup(path);
>  
>                               /* FIXME: missing OOM check here! */
> +                             if (name[strlen(name)-1] == '/')
> +                                     sprintf(path, "%s%s", tmp,
> +                                             name+((name[0] == '/') ?
> +                                                     1 : 0));
> +                             else
> +                                     sprintf(path, "%s%s/", tmp,
> +                                             name+((name[0] == '/') ?
> +                                                     1 : 0));

1) the patch removes '/' from beginning of the path. I don't say it's
wrong, I just don't know why.
<- If there already is '/' character = path like "/abc/", there is no need to 
add / thus have path like "/abc//", without this patch and the next path which 
is posted useless "/" are trimed at the end, which is not nice. Better way is 
not to add them at the beginning.

2) please use snprintf(), as in the old code.
<- thanks good catch

>  
> -                             snprintf(path, FILENAME_MAX, "%s%s/",
> -                                     tmp, name);
>                               path[FILENAME_MAX-1] = '\0';
>                               free(tmp);
>                       }
> 
> 
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and 
> threat landscape has changed and how IT managers can respond. Discussions 
> will include endpoint security, mobile security and the latest in malware 
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> Libcg-devel mailing list
> Libcg-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/libcg-devel


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Libcg-devel mailing list
Libcg-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libcg-devel

Reply via email to