Whamcloud - gitweb
LU-4629 gss: fix few issues found by Klocwork Insight tool
[fs/lustre-release.git] / lustre / utils / lustre_rsync.c
index b5cde93..77f213d 100644 (file)
@@ -26,6 +26,8 @@
 /*
  * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
+ *
+ * Copyright (c) 2012, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -631,13 +633,23 @@ int lr_add_pc(const char *pfid, const char *tfid, const char *name)
         p = calloc(1, sizeof(*p));
         if (!p)
                 return -ENOMEM;
-        strcpy(p->pc_log.pcl_pfid, pfid);
-        strcpy(p->pc_log.pcl_tfid, tfid);
-        strcpy(p->pc_log.pcl_name, name);
+       if (strlen(pfid) > sizeof(p->pc_log.pcl_pfid)-1)
+               goto out_err;
+       strncpy(p->pc_log.pcl_pfid, pfid, sizeof(p->pc_log.pcl_pfid));
+       if (strlen(tfid) > sizeof(p->pc_log.pcl_tfid)-1)
+               goto out_err;
+       strncpy(p->pc_log.pcl_tfid, tfid, sizeof(p->pc_log.pcl_tfid));
+       if (strlen(name) > sizeof(p->pc_log.pcl_name)-1)
+               goto out_err;
+       strncpy(p->pc_log.pcl_name, name, sizeof(p->pc_log.pcl_name));
 
         p->pc_next = parents;
         parents = p;
         return 0;
+
+out_err:
+       free(p);
+       return -E2BIG;
 }
 
 void lr_cascade_move(const char *fid, const char *dest, struct lr_info *info)
@@ -1517,15 +1529,16 @@ int lr_replicate()
                 case CL_XATTR:
                         rc = lr_setxattr(info);
                         break;
-                case CL_CLOSE:
-                case CL_EXT:
-                case CL_OPEN:
-                case CL_IOCTL:
-                case CL_MARK:
-                        /* Nothing needs to be done for these entries */
-                default:
-                        break;
-                }
+               case CL_CLOSE:
+               case CL_EXT:
+               case CL_OPEN:
+               case CL_LAYOUT:
+               case CL_MARK:
+                       /* Nothing needs to be done for these entries */
+                       /* fallthrough */
+               default:
+                       break;
+               }
                DEBUG_EXIT(info, rc);
                 if (rc && rc != -ENOENT) {
                         lr_print_failure(info, rc);