From: Arran Cudbard-Bell Date: Sun, 10 Dec 2017 12:40:29 +0000 (+0000) Subject: Allow the decoder to decode empty packets X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7ce24d2afdfd141311c43d22eff40c5c90eeeaee;p=thirdparty%2Ffreeradius-server.git Allow the decoder to decode empty packets These are valid, as SIM/AKA Notifications are just ACKs of a previous notification sent be the server and contain no attributes. --- diff --git a/src/modules/rlm_eap/lib/sim/decode.c b/src/modules/rlm_eap/lib/sim/decode.c index 9b157402932..9ebc64de724 100644 --- a/src/modules/rlm_eap/lib/sim/decode.c +++ b/src/modules/rlm_eap/lib/sim/decode.c @@ -927,6 +927,16 @@ ssize_t fr_sim_decode_pair(TALLOC_CTX *ctx, vp_cursor_t *cursor, * Extracts the SUBTYPE and adds it an attribute, then decodes any TLVs in the * SIM/AKA/AKA' packet. * + * 0 1 2 3 + * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Code | Identifier | Length | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Type | Subtype | Reserved | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * + * The first byte of the data pointer should be the subtype. + * * @param[in] request the current request. * @param[in] decoded where to write decoded attributes. * @param[in] data to convert to pairs. @@ -955,12 +965,17 @@ int fr_sim_decode(REQUEST *request, vp_cursor_t *decoded, fr_pair_cursor_end(decoded); /* - * Check if we have enough data for a single attribute - * Minimum attribute size is 4 bytes, then + 3 for - * subtype and the reserved bytes. + * We need at least enough data for the subtype + * and reserved bytes. + * + * Note: Not all packets should contain attrs. + * When the client acknowledges an + * AKA-Notification from the server, the + * AKA-Notification is returns contains no + * attributes. */ - if (data_len < (3 + sizeof(uint32_t))) { - fr_strerror_printf("Packet data too small: %zu < %zu" , data_len, 3 + sizeof(uint32_t)); + if (data_len < 3) { + fr_strerror_printf("Packet data too small, expected at least 3 bytes got %zu bytes", data_len); return -1; } p += 3;