]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
config: fix buffer overrun in env_to_{vec,deq}()
authorSage Weil <sage@newdream.net>
Mon, 13 Sep 2010 03:38:05 +0000 (20:38 -0700)
committerSage Weil <sage@newdream.net>
Mon, 13 Sep 2010 03:38:05 +0000 (20:38 -0700)
src/config.cc

index 305789a21fbc23b2ac78595c49835bf1b46a9d98..92cbf6723d40e5beee50a1932c485285722fd545 100644 (file)
@@ -104,8 +104,8 @@ void env_to_vec(std::vector<const char*>& args)
   char *p = getenv("CEPH_ARGS");
   if (!p) return;
   
-  int len = MIN(strlen(p), 1000);  // bleh.
   static char buf[1000];  
+  int len = MIN(strlen(p), sizeof(buf)-1);  // bleh.
   memcpy(buf, p, len);
   buf[len] = 0;
   //cout << "CEPH_ARGS='" << p << ";" << endl;
@@ -127,8 +127,8 @@ void env_to_deq(std::deque<const char*>& args)
   char *p = getenv("CEPH_ARGS");
   if (!p) return;
   
-  int len = MIN(strlen(p), 1000);  // bleh.
   static char buf[1000];  
+  int len = MIN(strlen(p), sizeof(buf)-1);  // bleh.
   memcpy(buf, p, len);
   buf[len] = 0;