From: Loic Dachary Date: Wed, 1 Jan 2014 20:23:18 +0000 (+0100) Subject: common: CEPH_ARGS should trim whitespaces X-Git-Tag: v0.77~64^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=07f5399408b080d775786e45a5055cc0772741dc;p=ceph.git common: CEPH_ARGS should trim whitespaces CEPH_ARGS when parsed by env_to_vec did not trim trailing and leading whitespaces: they would unexpectedly be parsed as empty arguments and lead to confusing errors such as : CEPH_ARGS=' --id 3' ceph-conf --lookup mon-data unable to parse option: '' The parsing code is replaced with str_vec(). It also resolves the problem of the hard limit to 1000 characters imposed by the static buffer that would silently truncate any CEPH_ARGS content. Signed-off-by: Loic Dachary --- diff --git a/src/common/ceph_argparse.cc b/src/common/ceph_argparse.cc index 245b38e234a..6d1c613c922 100644 --- a/src/common/ceph_argparse.cc +++ b/src/common/ceph_argparse.cc @@ -64,22 +64,13 @@ void env_to_vec(std::vector& args, const char *name) if (!p) return; - static char buf[1000]; - int len = MIN(strlen(p), sizeof(buf)-1); // bleh. - memcpy(buf, p, len); - buf[len] = 0; - //cout << "CEPH_ARGS='" << p << ";" << endl; - - p = buf; - while (*p && p < buf + len) { - char *e = p; - while (*e && *e != ' ') - e++; - *e = 0; - args.push_back(p); - //cout << "arg " << p << std::endl; - p = e+1; - } + static vector str_vec; + str_vec.clear(); + get_str_vec(p, " ", str_vec); + for (vector::iterator i = str_vec.begin(); + i != str_vec.end(); + i++) + args.push_back(i->c_str()); } void argv_to_vec(int argc, const char **argv,