diff options
author | Mark Spruiell <mes@zeroc.com> | 2002-10-12 00:13:40 +0000 |
---|---|---|
committer | Mark Spruiell <mes@zeroc.com> | 2002-10-12 00:13:40 +0000 |
commit | 17173387a237b2da8f61780d269e25a78f317cf5 (patch) | |
tree | 732320c904414575b4e64383dd6f9235bc571c6b /cpp/src/Ice/IdentityUtil.cpp | |
parent | bug fix (diff) | |
download | ice-17173387a237b2da8f61780d269e25a78f317cf5.tar.bz2 ice-17173387a237b2da8f61780d269e25a78f317cf5.tar.xz ice-17173387a237b2da8f61780d269e25a78f317cf5.zip |
validate identities
Diffstat (limited to 'cpp/src/Ice/IdentityUtil.cpp')
-rw-r--r-- | cpp/src/Ice/IdentityUtil.cpp | 40 |
1 files changed, 29 insertions, 11 deletions
diff --git a/cpp/src/Ice/IdentityUtil.cpp b/cpp/src/Ice/IdentityUtil.cpp index bf089c9b8c0..3a419b7ca74 100644 --- a/cpp/src/Ice/IdentityUtil.cpp +++ b/cpp/src/Ice/IdentityUtil.cpp @@ -28,36 +28,54 @@ Ice::stringToIdentity(const string& s) Identity ident; // - // Find unescaped separator + // Find unescaped separator. // - string::size_type slash = 0; - while((slash = s.find('/', slash)) != string::npos) + string::size_type slash = string::npos, pos = 0; + while((pos = s.find('/', pos)) != string::npos) { - if(slash == 0 || s[slash - 1] != '\\') + if(pos == 0 || s[pos - 1] != '\\') { - break; + if(slash == string::npos) + { + slash = pos; + } + else + { + // + // Extra unescaped slash found. + // + IdentityParseException ex(__FILE__, __LINE__); + ex.str = s; + throw ex; + } } - slash++; + pos++; } if(slash == string::npos) { - if(!decodeString(s, 0, 0, ident.name)) + if(!decodeString(s, 0, s.size(), ident.name)) { - throw SyscallException(__FILE__, __LINE__); + IdentityParseException ex(__FILE__, __LINE__); + ex.str = s; + throw ex; } } else { if(!decodeString(s, 0, slash, ident.category)) { - throw SyscallException(__FILE__, __LINE__); + IdentityParseException ex(__FILE__, __LINE__); + ex.str = s; + throw ex; } if(slash + 1 < s.size()) { - if(!decodeString(s, slash + 1, 0, ident.name)) + if(!decodeString(s, slash + 1, s.size(), ident.name)) { - throw SyscallException(__FILE__, __LINE__); + IdentityParseException ex(__FILE__, __LINE__); + ex.str = s; + throw ex; } } } |