]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: humor coverity
authorSage Weil <sage@inktank.com>
Sat, 27 Jul 2013 00:14:44 +0000 (17:14 -0700)
committerSage Weil <sage@inktank.com>
Sat, 27 Jul 2013 00:14:44 +0000 (17:14 -0700)
CID 1058392: Out-of-bounds access (OVERRUN_DYNAMIC) [select issue]

CID 1058391 (#1 of 1): Out-of-bounds access (OVERRUN)
32. alloc_strlen: Allocating insufficient memory for the terminating null of the string.

CID 1058390 (#1 of 1): Unchecked return value from library (CHECKED_RETURN)
13. check_return: Calling function "this->class_handler->open_all_classes()" without checking return value. It wraps a library function that may fail and return an error code. [show details]
     14. unchecked_value: No check of the return value of "this->class_handler->open_all_classes()".

Signed-off-by: Sage Weil <sage@inktank.com>
src/osd/ClassHandler.cc
src/osd/OSD.cc

index 3cc319efabeef622afb2b898e30e50d468eae31b..a9a920ba078e9640e5bb119411e998c2d8977941 100644 (file)
@@ -52,7 +52,7 @@ int ClassHandler::open_all_classes()
     if (strlen(pde->d_name) > sizeof(CLS_PREFIX) - 1 + sizeof(CLS_SUFFIX) - 1 &&
        strncmp(pde->d_name, CLS_PREFIX, sizeof(CLS_PREFIX) - 1) == 0 &&
        strcmp(pde->d_name + strlen(pde->d_name) - (sizeof(CLS_SUFFIX) - 1), CLS_SUFFIX) == 0) {
-      char cname[strlen(pde->d_name)];
+      char cname[PATH_MAX + 1];
       strcpy(cname, pde->d_name + sizeof(CLS_PREFIX) - 1);
       cname[strlen(cname) - (sizeof(CLS_SUFFIX) - 1)] = '\0';
       dout(10) << __func__ << " found " << cname << dendl;
index a2cc0ed229e6b943bd5a3fea9d4ca5780e6a20e1..e3a7c227e155323cdf2828b8608494d1727a67da 100644 (file)
@@ -1167,8 +1167,11 @@ int OSD::init()
   class_handler = new ClassHandler();
   cls_initialize(class_handler);
 
-  if (g_conf->osd_open_classes_on_start)
-    class_handler->open_all_classes();
+  if (g_conf->osd_open_classes_on_start) {
+    int r = class_handler->open_all_classes();
+    if (r)
+      dout(1) << "warning: got an error loading one or more classes: " << cpp_strerror(r) << dendl;
+  }
 
   // load up "current" osdmap
   assert_warn(!osdmap);