diff options
Diffstat (limited to 'libbb/concat_path_file.c')
-rw-r--r-- | libbb/concat_path_file.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/libbb/concat_path_file.c b/libbb/concat_path_file.c index d53dc0e2e..ce92310ea 100644 --- a/libbb/concat_path_file.c +++ b/libbb/concat_path_file.c | |||
@@ -15,9 +15,11 @@ extern char *concat_path_file(const char *path, const char *filename) | |||
15 | int flg_slash = 1; | 15 | int flg_slash = 1; |
16 | 16 | ||
17 | l = strlen(path); | 17 | l = strlen(path); |
18 | if(l>0 && path[l-1] == '/') | 18 | if (l>0 && path[l-1] == '/') |
19 | flg_slash--; | 19 | flg_slash--; |
20 | l += strlen(filename); | 20 | l += strlen(filename); |
21 | if (l>0 && filename[0] == '/') | ||
22 | flg_slash--; | ||
21 | outbuf = xmalloc(l+1+flg_slash); | 23 | outbuf = xmalloc(l+1+flg_slash); |
22 | sprintf(outbuf, (flg_slash ? "%s/%s" : "%s%s"), path, filename); | 24 | sprintf(outbuf, (flg_slash ? "%s/%s" : "%s%s"), path, filename); |
23 | return outbuf; | 25 | return outbuf; |