From cec9bc5f3aac6800c00690380d88be3b806479fa Mon Sep 17 00:00:00 2001 From: "ggtakec@gmail.com" Date: Mon, 15 Apr 2013 19:47:09 +0000 Subject: [PATCH] Fixed issue: 293 1) Command line argument bucket: causes segv(Issue: 293) If it specifies the bucket name which is terminated ":", s3fs run and crush(segv). This bug is fixed. git-svn-id: http://s3fs.googlecode.com/svn/trunk@409 df820570-a93a-0410-bd06-b72b767a4274 --- src/s3fs.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/s3fs.cpp b/src/s3fs.cpp index 43e14ed..160de81 100644 --- a/src/s3fs.cpp +++ b/src/s3fs.cpp @@ -3838,17 +3838,20 @@ static int my_fuse_opt_proc(void *data, const char *arg, int key, struct fuse_ar // the first NONOPT option is the bucket name if(bucket.size() == 0) { // extract remote mount path - char *bucket_name = (char *) arg; - if(strstr(arg, ":")) { + char *bucket_name = (char*)arg; + if(strstr(arg, ":")){ bucket = strtok(bucket_name, ":"); - mount_prefix = strtok(NULL, ":"); - // remove trailing slash - if(mount_prefix.at(mount_prefix.size() - 1) == '/') - mount_prefix = mount_prefix.substr(0, mount_prefix.size() - 1); - } else { + char* pmount_prefix = strtok(NULL, ":"); + if(pmount_prefix){ + mount_prefix = pmount_prefix; + // remove trailing slash + if(mount_prefix.at(mount_prefix.size() - 1) == '/'){ + mount_prefix = mount_prefix.substr(0, mount_prefix.size() - 1); + } + } + }else{ bucket = arg; } - return 0; }