mirror of
https://github.com/ceph/ceph
synced 2025-04-11 04:02:04 +00:00
filepath: don't parse multiple slashes as multiple dname bits.
This causes all kinds of trouble if it occurs because most of the code isn't prepared for it. So prevent that from happening except on messages that were explicitly created that way. Signed-off-by: Greg Farnum <gregory.farnum@dreamhost.com>
This commit is contained in:
parent
d1fcffad6c
commit
a851a1556f
@ -42,6 +42,7 @@ class filepath {
|
||||
* NOTE: this value is LAZILY maintained... i.e. it's a cache
|
||||
*/
|
||||
mutable vector<string> bits;
|
||||
bool encoded;
|
||||
|
||||
void rebuild_path() {
|
||||
path.clear();
|
||||
@ -57,21 +58,28 @@ class filepath {
|
||||
int nextslash = path.find('/', off);
|
||||
if (nextslash < 0)
|
||||
nextslash = path.length(); // no more slashes
|
||||
if (((nextslash - off) > 0) || encoded) {
|
||||
// skip empty components unless they were introduced deliberately
|
||||
// see commit message for more detail
|
||||
bits.push_back( path.substr(off,nextslash-off) );
|
||||
assert(encoded || bits.back().size());
|
||||
assert(encoded || bits.back().compare("/"));
|
||||
}
|
||||
off = nextslash+1;
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
filepath() : ino(0) { }
|
||||
filepath(const string& s, inodeno_t i) : ino(i), path(s) { }
|
||||
filepath(const char* s, inodeno_t i) : ino(i), path(s) { }
|
||||
filepath() : ino(0), encoded(false) { }
|
||||
filepath(const string& s, inodeno_t i) : ino(i), path(s), encoded(false) { }
|
||||
filepath(const char* s, inodeno_t i) : ino(i), path(s), encoded(false) { }
|
||||
filepath(const filepath& o) {
|
||||
ino = o.ino;
|
||||
path = o.path;
|
||||
bits = o.bits;
|
||||
encoded = o.encoded;
|
||||
}
|
||||
filepath(inodeno_t i) : ino(i) { }
|
||||
filepath(inodeno_t i) : ino(i), encoded(false) { }
|
||||
|
||||
void set_path(const char *s, inodeno_t b) {
|
||||
path = s;
|
||||
@ -187,6 +195,7 @@ class filepath {
|
||||
::decode(struct_v, blp);
|
||||
::decode(ino, blp);
|
||||
::decode(path, blp);
|
||||
encoded = true;
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user