]> git.ipfire.org Git - thirdparty/rsync.git/commitdiff
Use full MD4 len for archaic protocol auth.
authorWayne Davison <wayned@samba.org>
Mon, 30 Oct 2017 16:11:16 +0000 (09:11 -0700)
committerWayne Davison <wayned@samba.org>
Mon, 30 Oct 2017 20:34:18 +0000 (13:34 -0700)
authenticate.c
checksum.c

index a106b0f60a8cb88e37080bc5e2a58ce28c66f379..519429dc6b82708ed61eedc588c2179fdc8068aa 100644 (file)
@@ -22,7 +22,6 @@
 #include "itypes.h"
 
 extern int read_only;
-extern int protocol_version;
 extern char *password_file;
 
 /***************************************************************************
@@ -75,6 +74,8 @@ static void gen_challenge(const char *addr, char *challenge)
        sum_init(-1, 0);
        sum_update(input, sizeof input);
        len = sum_end(digest);
+       if (len == 2) /* The archaic checksum is 2 bytes, but sum_end() filled in the full MD4 checksum for us. */
+               len = MD4_DIGEST_LEN;
 
        base64_encode(digest, len, challenge, 0);
 }
@@ -90,6 +91,8 @@ static void generate_hash(const char *in, const char *challenge, char *out)
        sum_update(in, strlen(in));
        sum_update(challenge, strlen(challenge));
        len = sum_end(buf);
+       if (len == 2) /* The archaic checksum is 2 bytes, but sum_end() filled in the full MD4 checksum for us. */
+               len = MD4_DIGEST_LEN;
 
        base64_encode(buf, len, out, 0);
 }
@@ -238,11 +241,6 @@ char *auth_server(int f_in, int f_out, int module, const char *host,
        if (!users || !*users)
                return "";
 
-       if (protocol_version < 21) { /* Don't allow a weak checksum for the password. */
-               rprintf(FERROR, "ERROR: protocol version is too old!\n");
-               exit_cleanup(RERR_PROTOCOL);
-       }
-
        gen_challenge(addr, challenge);
 
        io_printf(f_out, "%s%s\n", leader, challenge);
index c119f972525341c2165c4b5bcb42612c8c983333..741ad7dfb63a8205db555127f10a36cb0c8c6757 100644 (file)
@@ -86,6 +86,8 @@ int csum_len_for_type(int cst)
                return MD4_DIGEST_LEN;
          case CSUM_MD5:
                return MD5_DIGEST_LEN;
+         default: /* paranoia to prevent missing case values */
+               exit_cleanup(RERR_UNSUPPORTED);
        }
        return 0;
 }
@@ -181,6 +183,8 @@ void get_checksum2(char *buf, int32 len, char *sum)
                mdfour_result(&m, (uchar *)sum);
                break;
          }
+         default: /* paranoia to prevent missing case values */
+               exit_cleanup(RERR_UNSUPPORTED);
        }
 }
 
@@ -275,6 +279,8 @@ void sum_init(int csum_type, int seed)
                break;
          case CSUM_NONE:
                break;
+         default: /* paranoia to prevent missing case values */
+               exit_cleanup(RERR_UNSUPPORTED);
        }
 }
 
@@ -322,6 +328,8 @@ void sum_update(const char *p, int32 len)
                break;
          case CSUM_NONE:
                break;
+         default: /* paranoia to prevent missing case values */
+               exit_cleanup(RERR_UNSUPPORTED);
        }
 }
 
@@ -349,6 +357,8 @@ int sum_end(char *sum)
          case CSUM_NONE:
                *sum = '\0';
                break;
+         default: /* paranoia to prevent missing case values */
+               exit_cleanup(RERR_UNSUPPORTED);
        }
 
        return csum_len_for_type(cursum_type);