]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
FlatIndex: terminate dir_name buffer passed to strncpy
authorSamuel Just <sam.just@inktank.com>
Tue, 25 Sep 2012 22:47:34 +0000 (15:47 -0700)
committerSamuel Just <sam.just@inktank.com>
Wed, 26 Sep 2012 17:16:24 +0000 (10:16 -0700)
CID 716836: Buffer not null terminated (BUFFER_SIZE_WARNING)At (1): Calling
strncpy with a maximum size argument of 4096 bytes on destination array
"dir_name" of size 4096 bytes might leave the destination string unterminated.

Signed-off-by: Samuel Just <sam.just@inktank.com>
src/os/FlatIndex.cc

index 7a1bfba43adf7fff2ec5f6a067b045752b7d8a61..b3d79f541951bceb867622d686346238f17baa68 100644 (file)
@@ -390,6 +390,7 @@ int FlatIndex::collection_list_partial(const hobject_t &start,
 int FlatIndex::collection_list(vector<hobject_t> *ls) {
   char dir_name[PATH_MAX], buf[PATH_MAX], new_name[PATH_MAX];
   strncpy(dir_name, base_path.c_str(), sizeof(dir_name));
+  dir_name[sizeof(dir_name)-1]='\0';
 
   DIR *dir = ::opendir(dir_name);
   if (!dir)