diff options
author | Sage Weil <sage@inktank.com> | 2013-02-09 21:36:58 -0800 |
---|---|---|
committer | Samuel Just <sam.just@inktank.com> | 2013-02-12 10:15:03 -0800 |
commit | 66ddffb721eb137d9859caee0b0a4c6b88a7692c (patch) | |
tree | 7314d53b4c1c3a58151a89c643ab160723017a73 | |
parent | 7edf8acfc1ed03e9d5add6a5f47a766663818b78 (diff) | |
download | ceph-66ddffb721eb137d9859caee0b0a4c6b88a7692c.tar.gz |
osd: make coll_t::is_pg() correctly validate the snapid suffix
The strtoull() man page suggests resetting errno and using that to
check for a parsing error. This ensures the OSD::load_pgs() callers are
getting what they expect (now that they aren't relying on the broken
behavior). The other callers in the os/* code is moved to a different
method that ignores the suffix.
Signed-off-by: Sage Weil <sage@inktank.com>
-rw-r--r-- | src/osd/osd_types.cc | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/osd/osd_types.cc b/src/osd/osd_types.cc index 3e2990e8b68..d6faa273c47 100644 --- a/src/osd/osd_types.cc +++ b/src/osd/osd_types.cc @@ -294,10 +294,14 @@ bool coll_t::is_pg(pg_t& pgid, snapid_t& snap) const const char *snap_start = strchr(cstr, '_'); if (!snap_start) return false; - if (strncmp(snap_start, "_head", 5) == 0) + if (strncmp(snap_start, "_head", 5) == 0) { snap = CEPH_NOSNAP; - else + } else { + errno = 0; snap = strtoull(snap_start+1, 0, 16); + if (errno) + return false; + } return true; } |