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.

97 lines
2.7 KiB

  1. commit bc112b0e7feece62ce98708092306639a8a53cce
  2. Author: Wayne Davison <wayned@samba.org>
  3. Date: Mon Oct 30 09:11:16 2017 -0700
  4. Use full MD4 len for archaic protocol auth.
  5. diff --git a/authenticate.c b/authenticate.c
  6. index a106b0f..519429d 100644
  7. --- a/authenticate.c
  8. +++ b/authenticate.c
  9. @@ -22,7 +22,6 @@
  10. #include "itypes.h"
  11. extern int read_only;
  12. -extern int protocol_version;
  13. extern char *password_file;
  14. /***************************************************************************
  15. @@ -75,6 +74,8 @@ static void gen_challenge(const char *addr, char *challenge)
  16. sum_init(-1, 0);
  17. sum_update(input, sizeof input);
  18. len = sum_end(digest);
  19. + if (len == 2) /* The archaic checksum is 2 bytes, but sum_end() filled in the full MD4 checksum for us. */
  20. + len = MD4_DIGEST_LEN;
  21. base64_encode(digest, len, challenge, 0);
  22. }
  23. @@ -90,6 +91,8 @@ static void generate_hash(const char *in, const char *challenge, char *out)
  24. sum_update(in, strlen(in));
  25. sum_update(challenge, strlen(challenge));
  26. len = sum_end(buf);
  27. + if (len == 2) /* The archaic checksum is 2 bytes, but sum_end() filled in the full MD4 checksum for us. */
  28. + len = MD4_DIGEST_LEN;
  29. base64_encode(buf, len, out, 0);
  30. }
  31. @@ -238,11 +241,6 @@ char *auth_server(int f_in, int f_out, int module, const char *host,
  32. if (!users || !*users)
  33. return "";
  34. - if (protocol_version < 21) { /* Don't allow a weak checksum for the password. */
  35. - rprintf(FERROR, "ERROR: protocol version is too old!\n");
  36. - exit_cleanup(RERR_PROTOCOL);
  37. - }
  38. -
  39. gen_challenge(addr, challenge);
  40. io_printf(f_out, "%s%s\n", leader, challenge);
  41. diff --git a/checksum.c b/checksum.c
  42. index c119f97..741ad7d 100644
  43. --- a/checksum.c
  44. +++ b/checksum.c
  45. @@ -86,6 +86,8 @@ int csum_len_for_type(int cst)
  46. return MD4_DIGEST_LEN;
  47. case CSUM_MD5:
  48. return MD5_DIGEST_LEN;
  49. + default: /* paranoia to prevent missing case values */
  50. + exit_cleanup(RERR_UNSUPPORTED);
  51. }
  52. return 0;
  53. }
  54. @@ -181,6 +183,8 @@ void get_checksum2(char *buf, int32 len, char *sum)
  55. mdfour_result(&m, (uchar *)sum);
  56. break;
  57. }
  58. + default: /* paranoia to prevent missing case values */
  59. + exit_cleanup(RERR_UNSUPPORTED);
  60. }
  61. }
  62. @@ -275,6 +279,8 @@ void sum_init(int csum_type, int seed)
  63. break;
  64. case CSUM_NONE:
  65. break;
  66. + default: /* paranoia to prevent missing case values */
  67. + exit_cleanup(RERR_UNSUPPORTED);
  68. }
  69. }
  70. @@ -322,6 +328,8 @@ void sum_update(const char *p, int32 len)
  71. break;
  72. case CSUM_NONE:
  73. break;
  74. + default: /* paranoia to prevent missing case values */
  75. + exit_cleanup(RERR_UNSUPPORTED);
  76. }
  77. }
  78. @@ -349,6 +357,8 @@ int sum_end(char *sum)
  79. case CSUM_NONE:
  80. *sum = '\0';
  81. break;
  82. + default: /* paranoia to prevent missing case values */
  83. + exit_cleanup(RERR_UNSUPPORTED);
  84. }
  85. return csum_len_for_type(cursum_type);