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.

91 lines
2.8 KiB

  1. # --- SDE-COPYRIGHT-NOTE-BEGIN ---
  2. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  3. #
  4. # Filename: package/.../rsync/CVE-2014-2855.patch
  5. # Copyright (C) 2014 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. X-Git-Url:
  17. https://git.samba.org/?p=rsync.git;a=blobdiff_plain;f=authenticate.c;h=c92746c6926f49e23fd38ce7b76c2e74d9c17df0;hp=3381b8c77a747a7a47a273f6272a6db6def1ed02;hb=0dedfbce2c1b851684ba658861fe9d620636c56a;hpb=4cad402ea8a91031f86c53961d78bb7f4f174790
  18. diff --git a/authenticate.c b/authenticate.c
  19. index 3381b8c..c92746c 100644
  20. --- a/authenticate.c
  21. +++ b/authenticate.c
  22. @@ -102,15 +102,16 @@ static const char *check_secret(int module, const char *user, const char *group,
  23. char pass2[MAX_DIGEST_LEN*2];
  24. const char *fname = lp_secrets_file(module);
  25. STRUCT_STAT st;
  26. - int fd, ok = 1;
  27. + int ok = 1;
  28. int user_len = strlen(user);
  29. int group_len = group ? strlen(group) : 0;
  30. char *err;
  31. + FILE *fh;
  32. - if (!fname || !*fname || (fd = open(fname, O_RDONLY)) < 0)
  33. + if (!fname || !*fname || (fh = fopen(fname, "r")) == NULL)
  34. return "no secrets file";
  35. - if (do_fstat(fd, &st) == -1) {
  36. + if (do_fstat(fileno(fh), &st) == -1) {
  37. rsyserr(FLOG, errno, "fstat(%s)", fname);
  38. ok = 0;
  39. } else if (lp_strict_modes(module)) {
  40. @@ -123,29 +124,30 @@ static const char *check_secret(int module, const char *user, const char *group,
  41. }
  42. }
  43. if (!ok) {
  44. - close(fd);
  45. + fclose(fh);
  46. return "ignoring secrets file";
  47. }
  48. if (*user == '#') {
  49. /* Reject attempt to match a comment. */
  50. - close(fd);
  51. + fclose(fh);
  52. return "invalid username";
  53. }
  54. /* Try to find a line that starts with the user (or @group) name and a ':'. */
  55. err = "secret not found";
  56. - while ((user || group) && read_line_old(fd, line, sizeof line, 1)) {
  57. - const char **ptr, *s;
  58. + while ((user || group) && fgets(line, sizeof line, fh) != NULL) {
  59. + const char **ptr, *s = strtok(line, "\n\r");
  60. int len;
  61. - if (*line == '@') {
  62. + if (!s)
  63. + continue;
  64. + if (*s == '@') {
  65. ptr = &group;
  66. len = group_len;
  67. - s = line+1;
  68. + s++;
  69. } else {
  70. ptr = &user;
  71. len = user_len;
  72. - s = line;
  73. }
  74. if (!*ptr || strncmp(s, *ptr, len) != 0 || s[len] != ':')
  75. continue;
  76. @@ -158,7 +160,7 @@ static const char *check_secret(int module, const char *user, const char *group,
  77. *ptr = NULL; /* Don't look for name again. */
  78. }
  79. - close(fd);
  80. + fclose(fh);
  81. memset(line, 0, sizeof line);
  82. memset(pass2, 0, sizeof pass2);