Matt McCutchen's Web Site
/
rsync
/
rsync.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
A small optimization to the symlink-send code, and an extra sanity
[rsync/rsync.git]
/
flist.c
diff --git
a/flist.c
b/flist.c
index
eaa1b2d
..
245a7ef
100644
(file)
--- a/
flist.c
+++ b/
flist.c
@@
-490,8
+490,9
@@
void send_file_entry(struct file_struct *file, int f, unsigned short base_flags)
#if SUPPORT_LINKS
if (preserve_links && S_ISLNK(mode)) {
#if SUPPORT_LINKS
if (preserve_links && S_ISLNK(mode)) {
- write_int(f, strlen(file->u.link));
- write_buf(f, file->u.link, strlen(file->u.link));
+ int len = strlen(file->u.link);
+ write_int(f, len);
+ write_buf(f, file->u.link, len);
}
#endif
}
#endif
@@
-643,14
+644,14
@@
void receive_file_entry(struct file_struct **fptr, unsigned short flags, int f)
}
if (preserve_links && S_ISLNK(mode)) {
}
if (preserve_links && S_ISLNK(mode)) {
- int l = read_int(f);
- if (l
< 0
) {
- rprintf(FERROR, "overflow: l
=%d\n", l
);
+ int l
en
= read_int(f);
+ if (l
en < 0 || len >= MAXPATHLEN
) {
+ rprintf(FERROR, "overflow: l
en=%d\n", len
);
overflow("receive_file_entry");
}
overflow("receive_file_entry");
}
- if (!(file->u.link = new_array(char, l + 1)))
+ if (!(file->u.link = new_array(char, l
en
+ 1)))
out_of_memory("receive_file_entry 2");
out_of_memory("receive_file_entry 2");
- read_sbuf(f, file->u.link, l);
+ read_sbuf(f, file->u.link, l
en
);
if (sanitize_paths)
sanitize_path(file->u.link, file->dirname);
}
if (sanitize_paths)
sanitize_path(file->u.link, file->dirname);
}