mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-30 08:49:26 +00:00
fix(ecstore): replace k.unwrap() with safe pattern in bucket_target_sys Replace unsafe k.unwrap().as_str() with if let Some(key_str) pattern in 5 locations where HeaderMap iterator yields (Option<HeaderName>, Value). This prevents potential panics if header names are invalid. Refs https://github.com/rustfs/backlog/issues/729
This commit is contained in:
@@ -1525,10 +1525,11 @@ impl TargetClient {
|
|||||||
.customize()
|
.customize()
|
||||||
.map_request(move |mut req| {
|
.map_request(move |mut req| {
|
||||||
for (k, v) in headers.clone().into_iter() {
|
for (k, v) in headers.clone().into_iter() {
|
||||||
let key_str = k.unwrap().as_str().to_string();
|
if let Some(key_str) = k.map(|k| k.as_str().to_string()) {
|
||||||
let value_str = v.to_str().unwrap_or("").to_string();
|
let value_str = v.to_str().unwrap_or("").to_string();
|
||||||
req.headers_mut().insert(key_str, value_str);
|
req.headers_mut().insert(key_str, value_str);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Result::<_, aws_smithy_types::error::operation::BuildError>::Ok(req)
|
Result::<_, aws_smithy_types::error::operation::BuildError>::Ok(req)
|
||||||
})
|
})
|
||||||
@@ -1586,10 +1587,11 @@ impl TargetClient {
|
|||||||
.customize()
|
.customize()
|
||||||
.map_request(move |mut req| {
|
.map_request(move |mut req| {
|
||||||
for (k, v) in headers.clone().into_iter() {
|
for (k, v) in headers.clone().into_iter() {
|
||||||
let key_str = k.unwrap().as_str().to_string();
|
if let Some(key_str) = k.map(|k| k.as_str().to_string()) {
|
||||||
let value_str = v.to_str().unwrap_or("").to_string();
|
let value_str = v.to_str().unwrap_or("").to_string();
|
||||||
req.headers_mut().insert(key_str, value_str);
|
req.headers_mut().insert(key_str, value_str);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Result::<_, aws_smithy_types::error::operation::BuildError>::Ok(req)
|
Result::<_, aws_smithy_types::error::operation::BuildError>::Ok(req)
|
||||||
})
|
})
|
||||||
.send()
|
.send()
|
||||||
@@ -1625,10 +1627,11 @@ impl TargetClient {
|
|||||||
.customize()
|
.customize()
|
||||||
.map_request(move |mut req| {
|
.map_request(move |mut req| {
|
||||||
for (k, v) in headers.clone().into_iter() {
|
for (k, v) in headers.clone().into_iter() {
|
||||||
let key_str = k.unwrap().as_str().to_string();
|
if let Some(key_str) = k.map(|k| k.as_str().to_string()) {
|
||||||
let value_str = v.to_str().unwrap_or("").to_string();
|
let value_str = v.to_str().unwrap_or("").to_string();
|
||||||
req.headers_mut().insert(key_str, value_str);
|
req.headers_mut().insert(key_str, value_str);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Result::<_, aws_smithy_types::error::operation::BuildError>::Ok(req)
|
Result::<_, aws_smithy_types::error::operation::BuildError>::Ok(req)
|
||||||
})
|
})
|
||||||
.send()
|
.send()
|
||||||
@@ -1661,10 +1664,11 @@ impl TargetClient {
|
|||||||
.customize()
|
.customize()
|
||||||
.map_request(move |mut req| {
|
.map_request(move |mut req| {
|
||||||
for (k, v) in headers.clone().into_iter() {
|
for (k, v) in headers.clone().into_iter() {
|
||||||
let key_str = k.unwrap().as_str().to_string();
|
if let Some(key_str) = k.map(|k| k.as_str().to_string()) {
|
||||||
let value_str = v.to_str().unwrap_or("").to_string();
|
let value_str = v.to_str().unwrap_or("").to_string();
|
||||||
req.headers_mut().insert(key_str, value_str);
|
req.headers_mut().insert(key_str, value_str);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Result::<_, aws_smithy_types::error::operation::BuildError>::Ok(req)
|
Result::<_, aws_smithy_types::error::operation::BuildError>::Ok(req)
|
||||||
})
|
})
|
||||||
.send()
|
.send()
|
||||||
@@ -1694,10 +1698,11 @@ impl TargetClient {
|
|||||||
.customize()
|
.customize()
|
||||||
.map_request(move |mut req| {
|
.map_request(move |mut req| {
|
||||||
for (k, v) in headers.clone().into_iter() {
|
for (k, v) in headers.clone().into_iter() {
|
||||||
let key_str = k.unwrap().as_str().to_string();
|
if let Some(key_str) = k.map(|k| k.as_str().to_string()) {
|
||||||
let value_str = v.to_str().unwrap_or("").to_string();
|
let value_str = v.to_str().unwrap_or("").to_string();
|
||||||
req.headers_mut().insert(key_str, value_str);
|
req.headers_mut().insert(key_str, value_str);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Result::<_, aws_smithy_types::error::operation::BuildError>::Ok(req)
|
Result::<_, aws_smithy_types::error::operation::BuildError>::Ok(req)
|
||||||
})
|
})
|
||||||
.send()
|
.send()
|
||||||
|
|||||||
Reference in New Issue
Block a user