cg_build_path adds needless "/" character in cases when / the input path
ends/starts with character "/" itself. This character is added now only in
cases it is waned and it was not set.

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));
 
-                               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

Reply via email to