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.

83 lines
1.9 KiB

  1. commit 4fc78878e01451d6465e2072f3f0653182f885c1
  2. Author: Wayne Davison <wayned@samba.org>
  3. Date: Sun May 1 16:29:34 2016 -0700
  4. Tweak indentation only.
  5. diff --git a/checksum.c b/checksum.c
  6. index 6ebb56b..bac775d 100644
  7. --- a/checksum.c
  8. +++ b/checksum.c
  9. @@ -188,32 +188,31 @@ void sum_update(const char *p, int32 len)
  10. {
  11. if (protocol_version >= 30) {
  12. md5_update(&md, (uchar *)p, len);
  13. - return;
  14. - }
  15. + } else {
  16. + if (len + sumresidue < CSUM_CHUNK) {
  17. + memcpy(md.buffer + sumresidue, p, len);
  18. + sumresidue += len;
  19. + return;
  20. + }
  21. - if (len + sumresidue < CSUM_CHUNK) {
  22. - memcpy(md.buffer + sumresidue, p, len);
  23. - sumresidue += len;
  24. - return;
  25. - }
  26. + if (sumresidue) {
  27. + int32 i = CSUM_CHUNK - sumresidue;
  28. + memcpy(md.buffer + sumresidue, p, i);
  29. + mdfour_update(&md, (uchar *)md.buffer, CSUM_CHUNK);
  30. + len -= i;
  31. + p += i;
  32. + }
  33. - if (sumresidue) {
  34. - int32 i = CSUM_CHUNK - sumresidue;
  35. - memcpy(md.buffer + sumresidue, p, i);
  36. - mdfour_update(&md, (uchar *)md.buffer, CSUM_CHUNK);
  37. - len -= i;
  38. - p += i;
  39. - }
  40. + while (len >= CSUM_CHUNK) {
  41. + mdfour_update(&md, (uchar *)p, CSUM_CHUNK);
  42. + len -= CSUM_CHUNK;
  43. + p += CSUM_CHUNK;
  44. + }
  45. - while (len >= CSUM_CHUNK) {
  46. - mdfour_update(&md, (uchar *)p, CSUM_CHUNK);
  47. - len -= CSUM_CHUNK;
  48. - p += CSUM_CHUNK;
  49. + sumresidue = len;
  50. + if (sumresidue)
  51. + memcpy(md.buffer, p, sumresidue);
  52. }
  53. -
  54. - sumresidue = len;
  55. - if (sumresidue)
  56. - memcpy(md.buffer, p, sumresidue);
  57. }
  58. int sum_end(char *sum)
  59. @@ -221,12 +220,12 @@ int sum_end(char *sum)
  60. if (protocol_version >= 30) {
  61. md5_result(&md, (uchar *)sum);
  62. return MD5_DIGEST_LEN;
  63. - }
  64. -
  65. - if (sumresidue || protocol_version >= 27)
  66. - mdfour_update(&md, (uchar *)md.buffer, sumresidue);
  67. + } else {
  68. + if (sumresidue || protocol_version >= 27)
  69. + mdfour_update(&md, (uchar *)md.buffer, sumresidue);
  70. - mdfour_result(&md, (uchar *)sum);
  71. + mdfour_result(&md, (uchar *)sum);
  72. - return MD4_DIGEST_LEN;
  73. + return MD4_DIGEST_LEN;
  74. + }
  75. }