]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: make coll_t::is_pg() correctly validate the snapid suffix
authorSage Weil <sage@inktank.com>
Sun, 10 Feb 2013 05:36:58 +0000 (21:36 -0800)
committerSamuel Just <sam.just@inktank.com>
Tue, 12 Feb 2013 18:15:03 +0000 (10:15 -0800)
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>
src/osd/osd_types.cc

index 3e2990e8b68c136b2125eab01b934845a31d78e2..d6faa273c47fcf962864167a12070809329988d3 100644 (file)
@@ -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;
 }