Skip to content

Commit cda1470

Browse files
authored
fix: RUSTSEC-2024-0421 by upgrading idna
https://rustsec.org/advisories/RUSTSEC-2024-0421.html Pull-Request: #5727.
1 parent 524afb4 commit cda1470

File tree

8 files changed

+358
-74
lines changed

8 files changed

+358
-74
lines changed

Cargo.lock

Lines changed: 326 additions & 56 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,13 @@ libp2p-autonat = { version = "0.13.2", path = "protocols/autonat" }
7878
libp2p-connection-limits = { version = "0.4.1", path = "misc/connection-limits" }
7979
libp2p-core = { version = "0.42.1", path = "core" }
8080
libp2p-dcutr = { version = "0.12.1", path = "protocols/dcutr" }
81-
libp2p-dns = { version = "0.42.0", path = "transports/dns" }
81+
libp2p-dns = { version = "0.42.1", path = "transports/dns" }
8282
libp2p-floodsub = { version = "0.45.0", path = "protocols/floodsub" }
8383
libp2p-gossipsub = { version = "0.48.0", path = "protocols/gossipsub" }
8484
libp2p-identify = { version = "0.46.0", path = "protocols/identify" }
8585
libp2p-identity = { version = "0.2.10" }
8686
libp2p-kad = { version = "0.47.1", path = "protocols/kad" }
87-
libp2p-mdns = { version = "0.46.0", path = "protocols/mdns" }
87+
libp2p-mdns = { version = "0.46.1", path = "protocols/mdns" }
8888
libp2p-memory-connection-limits = { version = "0.3.1", path = "misc/memory-connection-limits" }
8989
libp2p-metrics = { version = "0.15.0", path = "misc/metrics" }
9090
libp2p-mplex = { version = "0.42.0", path = "muxers/mplex" }
@@ -115,10 +115,13 @@ libp2p-webtransport-websys = { version = "0.4.1", path = "transports/webtranspor
115115
libp2p-yamux = { version = "0.46.0", path = "muxers/yamux" }
116116

117117
# External dependencies
118+
async-std-resolver = { version = "0.25.0-alpha.4", default-features = false }
118119
asynchronous-codec = { version = "0.7.0" }
119120
futures = "0.3.30"
120121
futures-bounded = { version = "0.2.4" }
121122
futures-rustls = { version = "0.26.0", default-features = false }
123+
hickory-proto = { version = "0.25.0-alpha.4", default-features = false }
124+
hickory-resolver = { version = "0.25.0-alpha.4", default-features = false }
122125
multiaddr = "0.18.1"
123126
multihash = "0.19.1"
124127
multistream-select = { version = "0.13.0", path = "misc/multistream-select" }

protocols/mdns/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 0.46.1
2+
3+
- Upgrade `hickory-proto`.
4+
See [PR 5727](https://github.com/libp2p/rust-libp2p/pull/5727)
5+
16
## 0.46.0
27

38
<!-- Update to libp2p-swarm v0.45.0 -->

protocols/mdns/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "libp2p-mdns"
33
edition = "2021"
44
rust-version = { workspace = true }
5-
version = "0.46.0"
5+
version = "0.46.1"
66
description = "Implementation of the libp2p mDNS discovery method"
77
authors = ["Parity Technologies <[email protected]>"]
88
license = "MIT"
@@ -24,7 +24,7 @@ smallvec = "1.13.2"
2424
socket2 = { version = "0.5.7", features = ["all"] }
2525
tokio = { workspace = true, default-features = false, features = ["net", "time"], optional = true}
2626
tracing = { workspace = true }
27-
hickory-proto = { version = "0.24.1", default-features = false, features = ["mdns"] }
27+
hickory-proto = { workspace = true, features = ["mdns"] }
2828

2929
[features]
3030
tokio = ["dep:tokio", "if-watch/tokio"]

protocols/mdns/src/behaviour/iface/query.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ impl MdnsPacket {
5151
pub(crate) fn new_from_bytes(
5252
buf: &[u8],
5353
from: SocketAddr,
54-
) -> Result<Option<MdnsPacket>, hickory_proto::error::ProtoError> {
54+
) -> Result<Option<MdnsPacket>, hickory_proto::ProtoError> {
5555
let packet = Message::from_vec(buf)?;
5656

5757
if packet.query().is_none() {
@@ -161,7 +161,7 @@ impl MdnsResponse {
161161
return None;
162162
}
163163

164-
let RData::PTR(record_value) = record.data()? else {
164+
let RData::PTR(record_value) = record.data() else {
165165
return None;
166166
};
167167

@@ -243,7 +243,7 @@ impl MdnsPeer {
243243
return None;
244244
}
245245

246-
if let Some(RData::TXT(ref txt)) = add_record.data() {
246+
if let RData::TXT(ref txt) = add_record.data() {
247247
Some(txt)
248248
} else {
249249
None
@@ -341,7 +341,7 @@ mod tests {
341341
if record.name().to_utf8() != SERVICE_NAME_FQDN {
342342
return None;
343343
}
344-
let Some(RData::PTR(record_value)) = record.data() else {
344+
let RData::PTR(record_value) = record.data() else {
345345
return None;
346346
};
347347
Some(record_value)

transports/dns/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 0.42.1
2+
3+
- Upgrade `async-std-resolver` and `hickory-resolver`.
4+
See [PR 5727](https://github.com/libp2p/rust-libp2p/pull/5727)
5+
16
## 0.42.0
27

38
- Implement refactored `Transport`.

transports/dns/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,21 @@ name = "libp2p-dns"
33
edition = "2021"
44
rust-version = { workspace = true }
55
description = "DNS transport implementation for libp2p"
6-
version = "0.42.0"
6+
version = "0.42.1"
77
authors = ["Parity Technologies <[email protected]>"]
88
license = "MIT"
99
repository = "https://github.com/libp2p/rust-libp2p"
1010
keywords = ["peer-to-peer", "libp2p", "networking"]
1111
categories = ["network-programming", "asynchronous"]
1212

1313
[dependencies]
14-
async-std-resolver = { version = "0.24", optional = true }
14+
async-std-resolver = { workspace = true, features = ["system-config"], optional = true }
1515
async-trait = "0.1.80"
1616
futures = { workspace = true }
1717
libp2p-core = { workspace = true }
1818
libp2p-identity = { workspace = true }
1919
parking_lot = "0.12.3"
20-
hickory-resolver = { version = "0.24.1", default-features = false, features = ["system-config"] }
20+
hickory-resolver = { workspace = true, features = ["system-config"] }
2121
smallvec = "1.13.2"
2222
tracing = { workspace = true }
2323

transports/dns/src/lib.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,12 @@ pub mod async_std {
117117
pub mod tokio {
118118
use std::sync::Arc;
119119

120-
use hickory_resolver::{system_conf, TokioAsyncResolver};
120+
use hickory_resolver::{system_conf, TokioResolver};
121121
use parking_lot::Mutex;
122122

123123
/// A `Transport` wrapper for performing DNS lookups when dialing `Multiaddr`esses
124124
/// using `tokio` for all async I/O.
125-
pub type Transport<T> = crate::Transport<T, TokioAsyncResolver>;
125+
pub type Transport<T> = crate::Transport<T, TokioResolver>;
126126

127127
impl<T> Transport<T> {
128128
/// Creates a new [`Transport`] from the OS's DNS configuration and defaults.
@@ -140,7 +140,7 @@ pub mod tokio {
140140
) -> Transport<T> {
141141
Transport {
142142
inner: Arc::new(Mutex::new(inner)),
143-
resolver: TokioAsyncResolver::tokio(cfg, opts),
143+
resolver: TokioResolver::tokio(cfg, opts),
144144
}
145145
}
146146
}
@@ -160,13 +160,12 @@ use async_trait::async_trait;
160160
use futures::{future::BoxFuture, prelude::*};
161161
pub use hickory_resolver::{
162162
config::{ResolverConfig, ResolverOpts},
163-
error::{ResolveError, ResolveErrorKind},
163+
{ResolveError, ResolveErrorKind},
164164
};
165165
use hickory_resolver::{
166166
lookup::{Ipv4Lookup, Ipv6Lookup, TxtLookup},
167167
lookup_ip::LookupIp,
168168
name_server::ConnectionProvider,
169-
AsyncResolver,
170169
};
171170
use libp2p_core::{
172171
multiaddr::{Multiaddr, Protocol},
@@ -594,7 +593,7 @@ pub trait Resolver {
594593
}
595594

596595
#[async_trait]
597-
impl<C> Resolver for AsyncResolver<C>
596+
impl<C> Resolver for hickory_resolver::Resolver<C>
598597
where
599598
C: ConnectionProvider,
600599
{
@@ -618,6 +617,7 @@ where
618617
#[cfg(all(test, any(feature = "tokio", feature = "async-std")))]
619618
mod tests {
620619
use futures::future::BoxFuture;
620+
use hickory_resolver::proto::{ProtoError, ProtoErrorKind};
621621
use libp2p_core::{
622622
multiaddr::{Multiaddr, Protocol},
623623
transport::{PortUse, TransportError, TransportEvent},
@@ -750,7 +750,8 @@ mod tests {
750750
.await
751751
{
752752
Err(Error::ResolveError(e)) => match e.kind() {
753-
ResolveErrorKind::NoRecordsFound { .. } => {}
753+
ResolveErrorKind::Proto(ProtoError { kind, .. })
754+
if matches!(kind.as_ref(), ProtoErrorKind::NoRecordsFound { .. }) => {}
754755
_ => panic!("Unexpected DNS error: {e:?}"),
755756
},
756757
Err(e) => panic!("Unexpected error: {e:?}"),

0 commit comments

Comments
 (0)