extern int preserve_uid;
extern int preserve_gid;
extern int preserve_times;
+extern int relative_paths;
static char **local_exclude_list = NULL;
last_gid = file->gid;
last_time = file->modtime;
- strcpy(lastname,file->name);
- lastname[255] = 0;
+ strncpy(lastname,file->name,MAXPATHLEN-1);
+ lastname[MAXPATHLEN-1] = 0;
}
last_gid = file->gid;
last_time = file->modtime;
- strcpy(lastname,file->name);
- lastname[255] = 0;
+ strncpy(lastname,file->name,MAXPATHLEN-1);
+ lastname[MAXPATHLEN-1] = 0;
}
if (!file) return;
if (flist->count >= flist->malloced) {
- flist->malloced += 100;
- flist->files = (struct file_struct *)realloc(flist->files,
- sizeof(flist->files[0])*
- flist->malloced);
- if (!flist->files)
- out_of_memory("send_file_name");
+ if (flist->malloced < 100)
+ flist->malloced += 100;
+ else
+ flist->malloced *= 1.8;
+ flist->files = (struct file_struct *)realloc(flist->files,
+ sizeof(flist->files[0])*
+ flist->malloced);
+ if (!flist->files)
+ out_of_memory("send_file_name");
}
if (strcmp(file->name,"/")) {
return;
}
- strcpy(fname,dir);
+ strncpy(fname,dir,MAXPATHLEN-1);
+ fname[MAXPATHLEN-1]=0;
l = strlen(fname);
- if (fname[l-1] != '/')
- strcat(fname,"/");
+ if (fname[l-1] != '/') {
+ strcat(fname,"/");
+ l++;
+ }
p = fname + strlen(fname);
if (cvs_exclude) {
if (strcmp(di->d_name,".")==0 ||
strcmp(di->d_name,"..")==0)
continue;
- strcpy(p,di->d_name);
+ strncpy(p,di->d_name,MAXPATHLEN-(l+1));
send_file_name(f,flist,fname);
}
char fname2[MAXPATHLEN];
char *fname = fname2;
- strcpy(fname,argv[i]);
+ strncpy(fname,argv[i],MAXPATHLEN-1);
+ fname[MAXPATHLEN-1] = 0;
l = strlen(fname);
if (l != 1 && fname[l-1] == '/') {
}
dir = NULL;
- p = strrchr(fname,'/');
- if (p) {
- *p = 0;
- if (p == fname)
- dir = "/";
- else
- dir = fname;
- fname = p+1;
+
+ if (!relative_paths) {
+ p = strrchr(fname,'/');
+ if (p) {
+ *p = 0;
+ if (p == fname)
+ dir = "/";
+ else
+ dir = fname;
+ fname = p+1;
+ }
}
+
if (!*fname)
fname = ".";
int i = flist->count;
if (i >= flist->malloced) {
- flist->malloced += 100;
- flist->files =(struct file_struct *)realloc(flist->files,
- sizeof(flist->files[0])*
- flist->malloced);
- if (!flist->files)
- goto oom;
+ if (flist->malloced < 100)
+ flist->malloced += 100;
+ else
+ flist->malloced *= 1.8;
+ flist->files =(struct file_struct *)realloc(flist->files,
+ sizeof(flist->files[0])*
+ flist->malloced);
+ if (!flist->files)
+ goto oom;
}
receive_file_entry(&flist->files[i],flags,f);
int flist_find(struct file_list *flist,struct file_struct *f)
{
- int low=0,high=flist->count;
+ int low=0,high=flist->count-1;
while (low != high) {
int mid = (low+high)/2;