]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
rust/base64: upgrade crate to latest
authorShivani Bhardwaj <shivani@oisf.net>
Thu, 29 Aug 2024 08:08:57 +0000 (13:38 +0530)
committerVictor Julien <victor@inliniac.net>
Mon, 9 Sep 2024 09:01:23 +0000 (11:01 +0200)
base64 crate is updated to the latest version 0.22.1. This came with
several API changes which are applied to the code. The old calls have
been replaced with the newer calls.

This was done following the availability of better fns to directly
decode into slices/vectors as needed and also that previous version was
too old.
Along with this change, update the Cargo.lock.in to reflect all changes
in the package versions.

Task 7219

rust/Cargo.lock.in
rust/Cargo.toml.in
rust/src/ffi/base64.rs
rust/src/http2/detect.rs
rust/src/http2/parser.rs
rust/src/jsonbuilder.rs

index 747e8e01d99b41569ee492c1c039f0a55e577053..0c412e1d5cb6b25970754685610c080e946b8f6f 100644 (file)
@@ -114,9 +114,9 @@ checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0"
 
 [[package]]
 name = "base64"
-version = "0.13.1"
+version = "0.22.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8"
+checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"
 
 [[package]]
 name = "bendy"
index 48e1d1f5104c70f69113b1c1c0acbd1b5b50e171..7ec8791ea8fc131a84126a6fbe698b4c0df4efbc 100644 (file)
@@ -58,7 +58,7 @@ sha1 = "~0.10.5"
 md-5 = "~0.10.1"
 regex = "~1.5.5"
 lazy_static = "~1.4.0"
-base64 = "~0.13.0"
+base64 = "~0.22.1"
 bendy = { version = "~0.3.3", default-features = false }
 asn1-rs = { version = "~0.6.1" }
 ldap-parser = { version = "~0.4.0" }
index ea72a344c393cb327b768c01be38446635dc36e2..e80dd5b5284aa4a279ce3f16c029de22a7c02c4b 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2021 Open Information Security Foundation
+/* Copyright (C) 2021-2024 Open Information Security Foundation
  *
  * You can copy, redistribute or modify this Program under the terms of
  * the GNU General Public License version 2 as published by the Free
@@ -17,6 +17,7 @@
 
 use std::os::raw::c_uchar;
 use libc::c_ulong;
+use base64::{Engine, engine::general_purpose::STANDARD};
 
 #[repr(C)]
 #[allow(non_camel_case_types)]
@@ -42,7 +43,7 @@ pub unsafe extern "C" fn Base64Encode(
         return Base64ReturnCode::SC_BASE64_INVALID_ARG;
     }
     let input = std::slice::from_raw_parts(input, input_len as usize);
-    let encoded = base64::encode(input);
+    let encoded = STANDARD.encode(input);
     if encoded.len() + 1 > *output_len as usize {
         return Base64ReturnCode::SC_BASE64_OVERFLOW;
     }
index b7a43ec522dc48b48c4c39a279ba396f7ee42599..74bb59223d1564c4bff7fd6fa2072ee71c5bd507 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2020 Open Information Security Foundation
+/* Copyright (C) 2020-2024 Open Information Security Foundation
  *
  * You can copy, redistribute or modify this Program under the terms of
  * the GNU General Public License version 2 as published by the Free
@@ -24,6 +24,7 @@ use crate::detect::uint::{detect_match_uint, DetectUintData};
 use std::ffi::CStr;
 use std::str::FromStr;
 use std::rc::Rc;
+use base64::{Engine, engine::general_purpose::STANDARD};
 
 fn http2_tx_has_frametype(
     tx: &mut HTTP2Transaction, direction: Direction, value: u8,
@@ -957,7 +958,7 @@ pub unsafe extern "C" fn rs_http2_tx_set_uri(
 }
 
 fn http2_tx_set_settings(state: &mut HTTP2State, input: &[u8]) {
-    match base64::decode(input) {
+    match STANDARD.decode(input) {
         Ok(dec) => {
             if dec.len() % 6 != 0 {
                 state.set_event(HTTP2Event::InvalidHTTP1Settings);
index 519d1b7bfb6dfff44ab46022b23f4eb33f1edc2e..239d4e942a8287a6db9ed91ef417719590524c37 100644 (file)
@@ -32,6 +32,7 @@ use nom7::{Err, IResult};
 use std::fmt;
 use std::str::FromStr;
 use std::rc::Rc;
+use base64::{Engine, engine::general_purpose::STANDARD_NO_PAD};
 
 #[repr(u8)]
 #[derive(Clone, Copy, PartialEq, Eq, FromPrimitive, Debug)]
@@ -762,7 +763,7 @@ pub fn http2_parse_frame_settings(i: &[u8]) -> IResult<&[u8], Vec<HTTP2FrameSett
 
 pub fn doh_extract_request(i: &[u8]) -> IResult<&[u8], Vec<u8>> {
     let (i, _) = tag("/dns-query?dns=")(i)?;
-    match base64::decode(i) {
+    match STANDARD_NO_PAD.decode(i) {
         Ok(dec) => {
             // i is unused
             return Ok((i, dec));
index bc09fb43cca7a95a37dc3dcbd8b21d888e0f5604..56fe91fcbd93ff074b9a8895dade3103cce3edc0 100644 (file)
@@ -24,6 +24,7 @@ use std::collections::TryReserveError;
 use std::ffi::CStr;
 use std::os::raw::c_char;
 use std::str::Utf8Error;
+use base64::{Engine, engine::general_purpose::STANDARD};
 
 const INIT_SIZE: usize = 4096;
 
@@ -807,7 +808,7 @@ impl JsonBuilder {
         if self.buf.capacity() < self.buf.len() + encoded_len {
             self.buf.try_reserve(encoded_len)?;
         }
-        base64::encode_config_buf(val, base64::STANDARD, &mut self.buf);
+        STANDARD.encode_string(val, &mut self.buf);
         Ok(self)
     }
 }