/*
* 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/
#include <libcfs/libcfsutil.h>
#include <lustre/lustreapi.h>
+#include <lustre/lustre_idl.h>
#include "lustre_rsync.h"
#define REPLICATE_STATUS_VER 1
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)
/* Initialize the replication parameters */
int lr_init_status()
{
- size_t size = sizeof(struct lustre_rsync_status) + PATH_MAX;
+ size_t size = sizeof(struct lustre_rsync_status) + PATH_MAX + 1;
if (status != NULL)
return 0;
struct lustre_rsync_status *s;
int fd = -1;
size_t size;
- size_t read_size = sizeof(struct lustre_rsync_status) + PATH_MAX;
+ size_t read_size = sizeof(struct lustre_rsync_status) + PATH_MAX + 1;
int rc = 0;
if (statuslog == NULL)
}
status->ls_num_targets = s->ls_num_targets;
memcpy(status->ls_targets, s->ls_targets,
- PATH_MAX * s->ls_num_targets);
+ (PATH_MAX + 1) * s->ls_num_targets);
}
if (status->ls_last_recno == -1)
status->ls_last_recno = s->ls_last_recno;
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);
status->ls_num_targets = numtargets;
}
newsize = sizeof (struct lustre_rsync_status) +
- (status->ls_num_targets * PATH_MAX);
+ (status->ls_num_targets * (PATH_MAX + 1));
if (status->ls_size != newsize) {
status->ls_size = newsize;
status = lr_grow_buf(status, newsize);
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",