OpenSDE Packages Database (without history before r20070)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

127 lines
3.9 KiB

  1. # --- SDE-COPYRIGHT-NOTE-BEGIN ---
  2. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  3. #
  4. # Filename: package/.../rsync/CVE-2014-9512.patch.disabled
  5. # Copyright (C) 2015 - 2020 The OpenSDE Project
  6. #
  7. # More information can be found in the files COPYING and README.
  8. #
  9. # This patch file is dual-licensed. It is available under the license the
  10. # patched project is licensed under, as long as it is an OpenSource license
  11. # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
  12. # of the GNU General Public License as published by the Free Software
  13. # Foundation; either version 2 of the License, or (at your option) any later
  14. # version.
  15. # --- SDE-COPYRIGHT-NOTE-END ---
  16. From 962f8b90045ab331fc04c9e65f80f1a53e68243b Mon Sep 17 00:00:00 2001
  17. From: Wayne Davison <wayned@samba.org>
  18. Date: Wed, 31 Dec 2014 12:41:03 -0800
  19. Subject: [PATCH] Complain if an inc-recursive path is not right for its dir.
  20. This ensures that a malicious sender can't use a just-sent symlink as a
  21. trasnfer path.
  22. ---
  23. flist.c | 22 ++++++++++++++++++++--
  24. io.c | 2 +-
  25. main.c | 4 ++--
  26. rsync.c | 2 +-
  27. diff --git a/flist.c b/flist.c
  28. index c24672e..92e4b65 100644
  29. --- a/flist.c
  30. +++ b/flist.c
  31. @@ -2435,8 +2435,9 @@ struct file_list *send_file_list(int f, int argc, char *argv[])
  32. return flist;
  33. }
  34. -struct file_list *recv_file_list(int f)
  35. +struct file_list *recv_file_list(int f, int dir_ndx)
  36. {
  37. + const char *good_dirname = NULL;
  38. struct file_list *flist;
  39. int dstart, flags;
  40. int64 start_read;
  41. @@ -2492,6 +2493,23 @@ struct file_list *recv_file_list(int f)
  42. flist_expand(flist, 1);
  43. file = recv_file_entry(f, flist, flags);
  44. + if (inc_recurse) {
  45. + static const char empty_dir[] = "\0";
  46. + const char *cur_dir = file->dirname ? file->dirname : empty_dir;
  47. + if (relative_paths && *cur_dir == '/')
  48. + cur_dir++;
  49. + if (cur_dir != good_dirname) {
  50. + const char *d = dir_ndx >= 0 ? f_name(dir_flist->files[dir_ndx], NULL) : empty_dir;
  51. + if (strcmp(cur_dir, d) != 0) {
  52. + rprintf(FERROR,
  53. + "ABORTING due to invalid dir prefix from sender: %s (should be: %s)\n",
  54. + cur_dir, d);
  55. + exit_cleanup(RERR_PROTOCOL);
  56. + }
  57. + good_dirname = cur_dir;
  58. + }
  59. + }
  60. +
  61. if (S_ISREG(file->mode)) {
  62. /* Already counted */
  63. } else if (S_ISDIR(file->mode)) {
  64. @@ -2615,7 +2633,7 @@ void recv_additional_file_list(int f)
  65. rprintf(FINFO, "[%s] receiving flist for dir %d\n",
  66. who_am_i(), ndx);
  67. }
  68. - flist = recv_file_list(f);
  69. + flist = recv_file_list(f, ndx);
  70. flist->parent_ndx = ndx;
  71. }
  72. }
  73. diff --git a/io.c b/io.c
  74. index b9a9bd0..a868fa9 100644
  75. --- a/io.c
  76. +++ b/io.c
  77. @@ -1685,7 +1685,7 @@ void wait_for_receiver(void)
  78. rprintf(FINFO, "[%s] receiving flist for dir %d\n",
  79. who_am_i(), ndx);
  80. }
  81. - flist = recv_file_list(iobuf.in_fd);
  82. + flist = recv_file_list(iobuf.in_fd, ndx);
  83. flist->parent_ndx = ndx;
  84. #ifdef SUPPORT_HARD_LINKS
  85. if (preserve_hard_links)
  86. diff --git a/main.c b/main.c
  87. index e7a13f7..713b818 100644
  88. --- a/main.c
  89. +++ b/main.c
  90. @@ -1009,7 +1009,7 @@ static void do_server_recv(int f_in, int f_out, int argc, char *argv[])
  91. filesfrom_fd = -1;
  92. }
  93. - flist = recv_file_list(f_in);
  94. + flist = recv_file_list(f_in, -1);
  95. if (!flist) {
  96. rprintf(FERROR,"server_recv: recv_file_list error\n");
  97. exit_cleanup(RERR_FILESELECT);
  98. @@ -1183,7 +1183,7 @@ int client_run(int f_in, int f_out, pid_t pid, int argc, char *argv[])
  99. if (write_batch && !am_server)
  100. start_write_batch(f_in);
  101. - flist = recv_file_list(f_in);
  102. + flist = recv_file_list(f_in, -1);
  103. if (inc_recurse && file_total == 1)
  104. recv_additional_file_list(f_in);
  105. diff --git a/rsync.c b/rsync.c
  106. index 68ff6b1..c3ecc51 100644
  107. --- a/rsync.c
  108. +++ b/rsync.c
  109. @@ -364,7 +364,7 @@ int read_ndx_and_attrs(int f_in, int f_out, int *iflag_ptr, uchar *type_ptr,
  110. }
  111. /* Send all the data we read for this flist to the generator. */
  112. start_flist_forward(ndx);
  113. - flist = recv_file_list(f_in);
  114. + flist = recv_file_list(f_in, ndx);
  115. flist->parent_ndx = ndx;
  116. stop_flist_forward();
  117. }
  118. --
  119. 1.9.1