]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
be less restrictive in the decoder which helps with CI
authorAlan T. DeKok <aland@freeradius.org>
Tue, 7 Feb 2023 16:15:06 +0000 (11:15 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Tue, 7 Feb 2023 16:15:06 +0000 (11:15 -0500)
src/listen/tacacs/proto_tacacs.c
src/protocols/tacacs/decode.c

index 93579d836d02994290c1182cc750e8f025101fe7..51c0306c94d7f332d75714958685d873748295d3 100644 (file)
@@ -207,7 +207,13 @@ static int mod_decode(void const *instance, request_t *request, uint8_t *const d
        request->packet->data_len = data_len;
 
        secret = client->secret;
-       if (secret) secretlen = talloc_array_length(client->secret) - 1;
+       if (secret) {
+               if (!packet_is_encrypted((fr_tacacs_packet_t const *) data)) {
+                       REDEBUG("Expected to see encrypted packet, got unencrypted packet!");
+                       return -1;
+               }
+               secretlen = talloc_array_length(client->secret) - 1;
+       }
 
        /*
         *      Note that we don't set a limit on max_attributes here.
index f7344ff7c5340cc4e996a03ee465eeda012e276b..dcf18839bfc12403cb3c31321b35f6ac053f6101 100644 (file)
@@ -425,11 +425,6 @@ ssize_t fr_tacacs_decode(TALLOC_CTX *ctx, fr_pair_list_t *out, uint8_t const *bu
                return -1;
        }
 
-       if (secret && !packet_is_encrypted(pkt)) {
-               fr_strerror_const("Packet is clear-text but we expected it to be encrypted");
-               return -1;
-       }
-
        /*
         *      Call the struct encoder to do the actual work.
         */
@@ -443,7 +438,7 @@ ssize_t fr_tacacs_decode(TALLOC_CTX *ctx, fr_pair_list_t *out, uint8_t const *bu
         *
         *      If there's a secret, we alway decrypt the packets.
         */
-       if (secret) {
+       if (secret && packet_is_encrypted(pkt)) {
                size_t length;
 
                if (!secret_len) {