rsync-2.5.1.patch-sec 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. Index: exclude.c
  2. diff -u exclude.c:1.38 exclude.c:1.39
  3. --- exclude.c:1.38 Wed Jun 20 23:15:34 2001
  4. +++ exclude.c Tue Jan 22 20:57:18 2002
  5. @@ -299,7 +299,8 @@
  6. void recv_exclude_list(int f)
  7. {
  8. char line[MAXPATHLEN];
  9. - int l;
  10. + unsigned int l;
  11. +
  12. while ((l=read_int(f))) {
  13. if (l >= MAXPATHLEN) overflow("recv_exclude_list");
  14. read_sbuf(f,line,l);
  15. Index: fileio.c
  16. diff -u fileio.c:1.3 fileio.c:1.4
  17. --- fileio.c:1.3 Wed Dec 30 06:48:45 1998
  18. +++ fileio.c Tue Jan 22 20:57:18 2002
  19. @@ -36,7 +36,7 @@
  20. }
  21. -static int write_sparse(int f,char *buf,int len)
  22. +static int write_sparse(int f,char *buf,size_t len)
  23. {
  24. int l1=0,l2=0;
  25. int ret;
  26. @@ -69,7 +69,7 @@
  27. -int write_file(int f,char *buf,int len)
  28. +int write_file(int f,char *buf,size_t len)
  29. {
  30. int ret = 0;
  31. Index: flist.c
  32. diff -u flist.c:1.102 flist.c:1.103
  33. --- flist.c:1.102 Tue Jan 15 03:50:32 2002
  34. +++ flist.c Tue Jan 22 20:57:18 2002
  35. @@ -375,7 +375,7 @@
  36. static gid_t last_gid;
  37. static char lastname[MAXPATHLEN];
  38. char thisname[MAXPATHLEN];
  39. - int l1=0,l2=0;
  40. + unsigned int l1=0,l2=0;
  41. char *p;
  42. struct file_struct *file;
  43. @@ -442,6 +442,10 @@
  44. if (preserve_links && S_ISLNK(file->mode)) {
  45. int l = read_int(f);
  46. + if (l < 0) {
  47. + rprintf(FERROR,"overflow: l=%d\n", l);
  48. + overflow("receive_file_entry");
  49. + }
  50. file->link = (char *)malloc(l+1);
  51. if (!file->link) out_of_memory("receive_file_entry 2");
  52. read_sbuf(f,file->link,l);
  53. Index: io.c
  54. diff -u io.c:1.87 io.c:1.88
  55. --- io.c:1.87 Sat Sep 8 21:42:09 2001
  56. +++ io.c Tue Jan 22 20:57:18 2002
  57. @@ -49,7 +49,7 @@
  58. static int io_error_fd = -1;
  59. -static void read_loop(int fd, char *buf, int len);
  60. +static void read_loop(int fd, char *buf, size_t len);
  61. static void check_timeout(void)
  62. {
  63. @@ -163,7 +163,7 @@
  64. * give a better explanation. We can tell whether the connection has
  65. * started by looking e.g. at whether the remote version is known yet.
  66. */
  67. -static int read_timeout (int fd, char *buf, int len)
  68. +static int read_timeout (int fd, char *buf, size_t len)
  69. {
  70. int n, ret=0;
  71. @@ -236,7 +236,7 @@
  72. /*! Continue trying to read len bytes - don't return until len has
  73. been read. */
  74. -static void read_loop (int fd, char *buf, int len)
  75. +static void read_loop (int fd, char *buf, size_t len)
  76. {
  77. while (len) {
  78. int n = read_timeout(fd, buf, len);
  79. @@ -253,7 +253,7 @@
  80. *
  81. * Never returns <= 0.
  82. */
  83. -static int read_unbuffered(int fd, char *buf, int len)
  84. +static int read_unbuffered(int fd, char *buf, size_t len)
  85. {
  86. static int remaining;
  87. int tag, ret=0;
  88. @@ -305,7 +305,7 @@
  89. /* do a buffered read from fd. don't return until all N bytes
  90. have been read. If all N can't be read then exit with an error */
  91. -static void readfd (int fd, char *buffer, int N)
  92. +static void readfd (int fd, char *buffer, size_t N)
  93. {
  94. int ret;
  95. int total=0;
  96. @@ -356,12 +356,12 @@
  97. return ret;
  98. }
  99. -void read_buf(int f,char *buf,int len)
  100. +void read_buf(int f,char *buf,size_t len)
  101. {
  102. readfd(f,buf,len);
  103. }
  104. -void read_sbuf(int f,char *buf,int len)
  105. +void read_sbuf(int f,char *buf,size_t len)
  106. {
  107. read_buf (f,buf,len);
  108. buf[len] = 0;
  109. @@ -375,7 +375,7 @@
  110. }
  111. /* write len bytes to fd */
  112. -static void writefd_unbuffered(int fd,char *buf,int len)
  113. +static void writefd_unbuffered(int fd,char *buf,size_t len)
  114. {
  115. int total = 0;
  116. fd_set w_fds, r_fds;
  117. @@ -483,7 +483,7 @@
  118. /* write an message to a multiplexed stream. If this fails then rsync
  119. exits */
  120. -static void mplex_write(int fd, enum logcode code, char *buf, int len)
  121. +static void mplex_write(int fd, enum logcode code, char *buf, size_t len)
  122. {
  123. char buffer[4096];
  124. int n = len;
  125. @@ -533,7 +533,7 @@
  126. }
  127. }
  128. -static void writefd(int fd,char *buf,int len)
  129. +static void writefd(int fd,char *buf,size_t len)
  130. {
  131. stats.total_written += len;
  132. @@ -587,7 +587,7 @@
  133. writefd(f,b,8);
  134. }
  135. -void write_buf(int f,char *buf,int len)
  136. +void write_buf(int f,char *buf,size_t len)
  137. {
  138. writefd(f,buf,len);
  139. }
  140. @@ -606,7 +606,7 @@
  141. -int read_line(int f, char *buf, int maxlen)
  142. +int read_line(int f, char *buf, size_t maxlen)
  143. {
  144. while (maxlen) {
  145. buf[0] = 0;
  146. @@ -664,7 +664,7 @@
  147. }
  148. /* write an message to the multiplexed error stream */
  149. -int io_multiplex_write(enum logcode code, char *buf, int len)
  150. +int io_multiplex_write(enum logcode code, char *buf, size_t len)
  151. {
  152. if (!io_multiplexing_out) return 0;
  153. Index: log.c
  154. diff -u log.c:1.53 log.c:1.54
  155. --- log.c:1.53 Mon Sep 3 20:12:55 2001
  156. +++ log.c Tue Jan 22 20:57:18 2002
  157. @@ -466,7 +466,7 @@
  158. l = strlen(n);
  159. - if ((l-1) + ((int)(s - &buf[0])) > sizeof(buf)) {
  160. + if (l + ((int)(s - &buf[0])) >= sizeof(buf)) {
  161. rprintf(FERROR,"buffer overflow expanding %%%c - exiting\n",
  162. p[0]);
  163. exit_cleanup(RERR_MESSAGEIO);
  164. Index: proto.h
  165. diff -u proto.h:1.133 proto.h:1.134
  166. --- proto.h:1.133 Sun Nov 25 23:18:09 2001
  167. +++ proto.h Tue Jan 22 20:57:18 2002
  168. @@ -15,10 +15,12 @@
  169. unsigned char read_batch_flags();
  170. void read_batch_flist_info(struct file_struct **fptr);
  171. void write_batch_csums_file(char *buff, int bytes_to_write);
  172. -void close_batch_csums_file() ;
  173. -void write_batch_csum_info(int *flist_entry, int flist_count, struct sum_struct *s);
  174. +void close_batch_csums_file();
  175. +void write_batch_csum_info(int *flist_entry, int flist_count,
  176. + struct sum_struct *s);
  177. int read_batch_csums_file(char *buff, int len);
  178. -void read_batch_csum_info(int flist_entry, struct sum_struct *s, int *checksums_match);
  179. +void read_batch_csum_info(int flist_entry, struct sum_struct *s,
  180. + int *checksums_match);
  181. void write_batch_delta_file(char *buff, int bytes_to_write);
  182. void close_batch_delta_file();
  183. int read_batch_delta_file(char *buff, int len);
  184. @@ -55,7 +57,7 @@
  185. void add_include_line(char *p);
  186. void add_cvs_excludes(void);
  187. int sparse_end(int f);
  188. -int write_file(int f,char *buf,int len);
  189. +int write_file(int f,char *buf,size_t len);
  190. struct map_struct *map_file(int fd,OFF_T len);
  191. char *map_ptr(struct map_struct *map,OFF_T offset,int len);
  192. void unmap_file(struct map_struct *map);
  193. @@ -81,21 +83,21 @@
  194. void io_set_error_fd(int fd);
  195. int32 read_int(int f);
  196. int64 read_longint(int f);
  197. -void read_buf(int f,char *buf,int len);
  198. -void read_sbuf(int f,char *buf,int len);
  199. +void read_buf(int f,char *buf,size_t len);
  200. +void read_sbuf(int f,char *buf,size_t len);
  201. unsigned char read_byte(int f);
  202. void io_start_buffering(int fd);
  203. void io_flush(void);
  204. void io_end_buffering(int fd);
  205. void write_int(int f,int32 x);
  206. void write_longint(int f, int64 x);
  207. -void write_buf(int f,char *buf,int len);
  208. +void write_buf(int f,char *buf,size_t len);
  209. void write_byte(int f,unsigned char c);
  210. -int read_line(int f, char *buf, int maxlen);
  211. +int read_line(int f, char *buf, size_t maxlen);
  212. void io_printf(int fd, const char *format, ...);
  213. void io_start_multiplex_out(int fd);
  214. void io_start_multiplex_in(int fd);
  215. -int io_multiplex_write(enum logcode code, char *buf, int len);
  216. +int io_multiplex_write(enum logcode code, char *buf, size_t len);
  217. void io_multiplexing_close(void);
  218. char *lp_motd_file(void);
  219. char *lp_log_file(void);
  220. @@ -166,6 +168,9 @@
  221. void sig_int(void);
  222. void finish_transfer(char *fname, char *fnametmp, struct file_struct *file);
  223. void send_files(struct file_list *flist,int f_out,int f_in);
  224. +int try_bind_local(int s,
  225. + int ai_family, int ai_socktype,
  226. + const char *bind_address);
  227. int open_socket_out(char *host, int port, const char *bind_address,
  228. int af_hint);
  229. int open_socket_out_wrapped (char *host,
  230. Index: receiver.c
  231. diff -u receiver.c:1.34 receiver.c:1.35
  232. --- receiver.c:1.34 Fri Jan 11 00:25:33 2002
  233. +++ receiver.c Tue Jan 22 20:57:18 2002
  234. @@ -206,7 +206,8 @@
  235. static int receive_data(int f_in,struct map_struct *buf,int fd,char *fname,
  236. OFF_T total_size)
  237. {
  238. - int i,n,remainder,len,count;
  239. + int i;
  240. + unsigned int n,remainder,len,count;
  241. OFF_T offset = 0;
  242. OFF_T offset2;
  243. char *data;
  244. Index: rsync.h
  245. diff -u rsync.h:1.116 rsync.h:1.117
  246. --- rsync.h:1.116 Fri Jan 11 00:37:42 2002
  247. +++ rsync.h Tue Jan 22 20:57:19 2002
  248. @@ -374,9 +374,9 @@
  249. struct sum_struct {
  250. OFF_T flength; /* total file length */
  251. - int count; /* how many chunks */
  252. - int remainder; /* flength % block_length */
  253. - int n; /* block_length */
  254. + size_t count; /* how many chunks */
  255. + size_t remainder; /* flength % block_length */
  256. + size_t n; /* block_length */
  257. struct sum_buf *sums; /* points to info for each chunk */
  258. };
  259. Index: util.c
  260. diff -u util.c:1.98 util.c:1.99
  261. --- util.c:1.98 Tue Jan 15 02:05:28 2002
  262. +++ util.c Tue Jan 22 20:57:19 2002
  263. @@ -275,7 +275,7 @@
  264. derived from GNU C's cccp.c.
  265. */
  266. -static int full_write(int desc, char *ptr, int len)
  267. +static int full_write(int desc, char *ptr, size_t len)
  268. {
  269. int total_written;
  270. @@ -301,11 +301,11 @@
  271. for an error.
  272. derived from GNU C's cccp.c. */
  273. -static int safe_read(int desc, char *ptr, int len)
  274. +static int safe_read(int desc, char *ptr, size_t len)
  275. {
  276. int n_chars;
  277. - if (len <= 0)
  278. + if (len == 0)
  279. return len;
  280. #ifdef EINTR