X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Futils%2Flustre_rsync.c;h=113dc04f09104c61347b6b7b647d37d1ae4f1305;hb=4a540ca0c37a5302c9696b2b626cbb61384c60be;hp=b5cde932bb040db469d86044b6005ce065310feb;hpb=7c6ba5c87cfacbb615a82d587509975e96b69da5;p=fs%2Flustre-release.git diff --git a/lustre/utils/lustre_rsync.c b/lustre/utils/lustre_rsync.c index b5cde93..113dc04 100644 --- a/lustre/utils/lustre_rsync.c +++ b/lustre/utils/lustre_rsync.c @@ -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); @@ -1674,6 +1687,8 @@ int main(int argc, char *argv[]) break; case 'D': /* Undocumented option debug log file */ + if (debug_log != NULL) + fclose(debug_log); debug_log = fopen(optarg, "a"); if (debug_log == NULL) { printf("Cannot open %s for debug log\n",