From 2b6150a8e53bd2e821645725ab0e7e35df1cd633 Mon Sep 17 00:00:00 2001 From: DarkCat09 Date: Thu, 1 Aug 2024 12:35:50 +0400 Subject: [PATCH] fix: allow all status codes with catch_all 10..69 range is still checked, see comment at L52 --- src/status.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/status.rs b/src/status.rs index e59bc3e..ca2c59e 100644 --- a/src/status.rs +++ b/src/status.rs @@ -48,6 +48,12 @@ pub enum StatusCode { ClientCerts = 60, CertNotAuthorized = 61, CertNotValid = 62, + + // 1..6 first digit range check is still + // covered by conversion into ReplyType + // (see Status::parse_status) + #[num_enum(catch_all)] + Unknown(u8), } const ASCII_ZERO: u8 = 48; // '0' @@ -58,9 +64,12 @@ impl Status { // '2' - '0' = 50 - 48 = 2 (from byte '2' to uint 2) let first = buf[0] - ASCII_ZERO; let second = buf[1] - ASCII_ZERO; + + let code = first * 10 + second; + Ok(Status { // get enum item for 2-digit status code - status_code: StatusCode::try_from_primitive(first * 10 + second)?, + status_code: StatusCode::try_from_primitive(code)?, // get enum entry for first digit reply_type: ReplyType::try_from_primitive(first)?, // provide separate field for the 2nd digit