aboutsummaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorandersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277>2001-05-04 22:04:24 +0000
committerandersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277>2001-05-04 22:04:24 +0000
commitb371eec2dfdb5882be87ecb3031a0d056a4c7cee (patch)
tree18212b9982894cbb0bafa7a675e9cc7f0fa6e3c3 /libbb
parent563296f0af9292a0285cdff2e5ccb0e84e186756 (diff)
downloadbusybox-w32-b371eec2dfdb5882be87ecb3031a0d056a4c7cee.tar.gz
busybox-w32-b371eec2dfdb5882be87ecb3031a0d056a4c7cee.tar.bz2
busybox-w32-b371eec2dfdb5882be87ecb3031a0d056a4c7cee.zip
Larry suggested using concat_path_file() would be an even safer bet
for 'which'. I ageed, so I whipped this up -- which revealed a bug in concat_path_file. It turns out that that a '/' can be appended from either the path _or_ the filename, but only the former was checked. -Erik git-svn-id: svn://busybox.net/trunk/busybox@2536 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'libbb')
-rw-r--r--libbb/concat_path_file.c4
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;