From: Sage Weil Date: Sun, 10 Feb 2013 05:36:58 +0000 (-0800) Subject: osd: make coll_t::is_pg() correctly validate the snapid suffix X-Git-Tag: v0.58~96^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=66ddffb721eb137d9859caee0b0a4c6b88a7692c;p=ceph.git 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 --- diff --git a/src/osd/osd_types.cc b/src/osd/osd_types.cc index 3e2990e8b68c..d6faa273c47f 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; }