!52 Update to 1.53.0

From: @sdlzx
Reviewed-by: @jingxiaolu
Signed-off-by: @jingxiaolu
This commit is contained in:
openeuler-ci-bot 2021-10-09 01:20:56 +00:00 committed by Gitee
commit fe38428fe7
4 changed files with 8 additions and 243 deletions

View File

@ -1,108 +0,0 @@
From 974192cd98b3efca8e5cd293f641f561e7487b30 Mon Sep 17 00:00:00 2001
From: Cheng XU <git@xuc.me>
Date: Tue, 30 Mar 2021 10:24:23 +0800
Subject: [PATCH] Disallow octal format in Ipv4 string
In its original specification, leading zero in Ipv4 string is interpreted
as octal literals. So a IP address 0127.0.0.1 actually means 87.0.0.1.
This confusion can lead to many security vulnerabilities. Therefore, in
[IETF RFC 6943], it suggests to disallow octal/hexadecimal format in Ipv4
string all together.
Existing implementation already disallows hexadecimal numbers. This commit
makes Parser reject octal numbers.
Fixes #83648.
[IETF RFC 6943]: https://tools.ietf.org/html/rfc6943#section-3.1.1
---
library/std/src/net/ip.rs | 2 ++
library/std/src/net/parser.rs | 14 +++++++++++++-
library/std/src/net/parser/tests.rs | 8 ++++++++
3 files changed, 23 insertions(+), 1 deletion(-)
diff --git a/library/std/src/net/ip.rs b/library/std/src/net/ip.rs
index 2aa305d7f831e..7f8c33dac561f 100644
--- a/library/std/src/net/ip.rs
+++ b/library/std/src/net/ip.rs
@@ -67,7 +67,9 @@ pub enum IpAddr {
///
/// `Ipv4Addr` provides a [`FromStr`] implementation. The four octets are in decimal
/// notation, divided by `.` (this is called "dot-decimal notation").
+/// Notably, octal numbers and hexadecimal numbers are not allowed per [IETF RFC 6943].
///
+/// [IETF RFC 6943]: https://tools.ietf.org/html/rfc6943#section-3.1.1
/// [`FromStr`]: crate::str::FromStr
///
/// # Examples
diff --git a/library/std/src/net/parser.rs b/library/std/src/net/parser.rs
index 7064ed3ed236d..88a8cb76befbf 100644
--- a/library/std/src/net/parser.rs
+++ b/library/std/src/net/parser.rs
@@ -67,6 +67,11 @@ impl<'a> Parser<'a> {
if self.state.is_empty() { result } else { None }.ok_or(AddrParseError(()))
}
+ /// Peek the next character from the input
+ fn peek_char(&self) -> Option<char> {
+ self.state.first().map(|&b| char::from(b))
+ }
+
/// Read the next character from the input
fn read_char(&mut self) -> Option<char> {
self.state.split_first().map(|(&b, tail)| {
@@ -132,7 +137,14 @@ impl<'a> Parser<'a> {
let mut groups = [0; 4];
for (i, slot) in groups.iter_mut().enumerate() {
- *slot = p.read_separator('.', i, |p| p.read_number(10, None))?;
+ *slot = p.read_separator('.', i, |p| {
+ // Disallow octal number in IP string.
+ // https://tools.ietf.org/html/rfc6943#section-3.1.1
+ match (p.peek_char(), p.read_number(10, None)) {
+ (Some('0'), Some(number)) if number != 0 => None,
+ (_, number) => number,
+ }
+ })?;
}
Some(groups.into())
diff --git a/library/std/src/net/parser/tests.rs b/library/std/src/net/parser/tests.rs
index 8d8889cd19d36..6d2d48ecad02f 100644
--- a/library/std/src/net/parser/tests.rs
+++ b/library/std/src/net/parser/tests.rs
@@ -8,11 +8,15 @@ const SCOPE_ID: u32 = 1337;
const IPV4: Ipv4Addr = Ipv4Addr::new(192, 168, 0, 1);
const IPV4_STR: &str = "192.168.0.1";
const IPV4_STR_PORT: &str = "192.168.0.1:8080";
+const IPV4_STR_WITH_OCTAL: &str = "0127.0.0.1";
+const IPV4_STR_WITH_HEX: &str = "0x10.0.0.1";
const IPV6: Ipv6Addr = Ipv6Addr::new(0x2001, 0xdb8, 0, 0, 0, 0, 0xc0a8, 0x1);
const IPV6_STR_FULL: &str = "2001:db8:0:0:0:0:c0a8:1";
const IPV6_STR_COMPRESS: &str = "2001:db8::c0a8:1";
const IPV6_STR_V4: &str = "2001:db8::192.168.0.1";
+const IPV6_STR_V4_WITH_OCTAL: &str = "2001:db8::0127.0.0.1";
+const IPV6_STR_V4_WITH_HEX: &str = "2001:db8::0x10.0.0.1";
const IPV6_STR_PORT: &str = "[2001:db8::c0a8:1]:8080";
const IPV6_STR_PORT_SCOPE_ID: &str = "[2001:db8::c0a8:1%1337]:8080";
@@ -22,6 +26,8 @@ fn parse_ipv4() {
assert_eq!(result, IPV4);
assert!(Ipv4Addr::from_str(IPV4_STR_PORT).is_err());
+ assert!(Ipv4Addr::from_str(IPV4_STR_WITH_OCTAL).is_err());
+ assert!(Ipv4Addr::from_str(IPV4_STR_WITH_HEX).is_err());
assert!(Ipv4Addr::from_str(IPV6_STR_FULL).is_err());
assert!(Ipv4Addr::from_str(IPV6_STR_COMPRESS).is_err());
assert!(Ipv4Addr::from_str(IPV6_STR_V4).is_err());
@@ -39,6 +45,8 @@ fn parse_ipv6() {
let result: Ipv6Addr = IPV6_STR_V4.parse().unwrap();
assert_eq!(result, IPV6);
+ assert!(Ipv6Addr::from_str(IPV6_STR_V4_WITH_OCTAL).is_err());
+ assert!(Ipv6Addr::from_str(IPV6_STR_V4_WITH_HEX).is_err());
assert!(Ipv6Addr::from_str(IPV4_STR).is_err());
assert!(Ipv6Addr::from_str(IPV4_STR_PORT).is_err());
assert!(Ipv6Addr::from_str(IPV6_STR_PORT).is_err());

View File

@ -1,39 +0,0 @@
From c2b79c6142da1a757f9b4a0b58883e39aade779c Mon Sep 17 00:00:00 2001
From: caodongxia <315816521@qq.com>
Date: Tue, 24 Aug 2021 09:11:28 +0800
Subject: [PATCH] fix rustdoc error info
---
compiler/rustc_session/src/config.rs | 2 +-
vendor/rustc-ap-rustc_session/src/config.rs | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs
index a6d4dcb34..ab8ef7a3c 100644
--- a/compiler/rustc_session/src/config.rs
+++ b/compiler/rustc_session/src/config.rs
@@ -891,7 +891,7 @@ pub fn build_target_config(opts: &Options, target_override: Option<Target>) -> T
opts.error_format,
&format!(
"Error loading target specification: {}. \
- Use `--print target-list` for a list of built-in targets",
+ Use `rustc --print target-list` for a list of built-in targets",
e
),
)
diff --git a/vendor/rustc-ap-rustc_session/src/config.rs b/vendor/rustc-ap-rustc_session/src/config.rs
index 9d73c3b44..223e4eead 100644
--- a/vendor/rustc-ap-rustc_session/src/config.rs
+++ b/vendor/rustc-ap-rustc_session/src/config.rs
@@ -891,7 +891,7 @@ pub fn build_target_config(opts: &Options, target_override: Option<Target>) -> T
opts.error_format,
&format!(
"Error loading target specification: {}. \
- Use `--print target-list` for a list of built-in targets",
+ Use `rustc --print target-list` for a list of built-in targets",
e
),
)
--
2.27.0

View File

@ -1,85 +0,0 @@
From 33ccf6af163e2d04a592cca506f334d905cb94aa Mon Sep 17 00:00:00 2001
From: Anders Kaseorg <andersk@mit.edu>
Date: Fri, 17 Sep 2021 00:19:22 -0400
Subject: [PATCH] bootstrap: Restore missing --bulk-dirs for rust-docs,
rustc-docs
---
src/bootstrap/dist.rs | 4 ++--
src/bootstrap/tarball.rs | 17 +++++++++++++++++
2 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs
index 86c84a2..aadbb98 100644
--- a/src/bootstrap/dist.rs
+++ b/src/bootstrap/dist.rs
@@ -74,7 +74,7 @@ impl Step for Docs {
let mut tarball = Tarball::new(builder, "rust-docs", &host.triple);
tarball.set_product_name("Rust Documentation");
- tarball.add_dir(&builder.doc_out(host), dest);
+ tarball.add_bulk_dir(&builder.doc_out(host), dest);
tarball.add_file(&builder.src.join("src/doc/robots.txt"), dest, 0o644);
Some(tarball.generate())
}
@@ -107,7 +107,7 @@ impl Step for RustcDocs {
let mut tarball = Tarball::new(builder, "rustc-docs", &host.triple);
tarball.set_product_name("Rustc Documentation");
- tarball.add_dir(&builder.compiler_doc_out(host), "share/doc/rust/html/rustc");
+ tarball.add_bulk_dir(&builder.compiler_doc_out(host), "share/doc/rust/html/rustc");
Some(tarball.generate())
}
}
diff --git a/src/bootstrap/tarball.rs b/src/bootstrap/tarball.rs
index 7fb0305..50f8605 100644
--- a/src/bootstrap/tarball.rs
+++ b/src/bootstrap/tarball.rs
@@ -94,6 +94,7 @@ pub(crate) struct Tarball<'a> {
temp_dir: PathBuf,
image_dir: PathBuf,
overlay_dir: PathBuf,
+ bulk_dirs: Vec<PathBuf>,
include_target_in_component_name: bool,
is_preview: bool,
@@ -132,6 +133,7 @@ impl<'a> Tarball<'a> {
temp_dir,
image_dir,
overlay_dir,
+ bulk_dirs: Vec::new(),
include_target_in_component_name: false,
is_preview: false,
@@ -196,6 +198,11 @@ impl<'a> Tarball<'a> {
self.builder.cp_r(src.as_ref(), &dest);
}
+ pub(crate) fn add_bulk_dir(&mut self, src: impl AsRef<Path>, dest: impl AsRef<Path>) {
+ self.bulk_dirs.push(dest.as_ref().to_path_buf());
+ self.add_dir(src, dest);
+ }
+
pub(crate) fn generate(self) -> GeneratedTarball {
let mut component_name = self.component.clone();
if self.is_preview {
@@ -216,6 +223,16 @@ impl<'a> Tarball<'a> {
.arg("--image-dir")
.arg(&this.image_dir)
.arg(format!("--component-name={}", &component_name));
+
+ if let Some((dir, dirs)) = this.bulk_dirs.split_first() {
+ let mut arg = dir.as_os_str().to_os_string();
+ for dir in dirs {
+ arg.push(",");
+ arg.push(dir);
+ }
+ cmd.arg("--bulk-dirs").arg(&arg);
+ }
+
this.non_bare_args(cmd);
})
}
--
1.8.3.1

View File

@ -1,9 +1,9 @@
%global rust_arches x86_64 i686 armv7hl aarch64 ppc64 ppc64le s390x
%{!?channel: %global channel stable}
%global bootstrap_rust 1.51.0
%global bootstrap_cargo 1.51.0
%global bootstrap_channel 1.51.0
%global bootstrap_date 2021-09-28
%global bootstrap_rust 1.52.1
%global bootstrap_cargo 1.52.1
%global bootstrap_channel 1.52.1
%global bootstrap_date 2021-10-02
%bcond_with llvm_static
%bcond_with bundled_llvm
%bcond_without bundled_libgit2
@ -11,7 +11,7 @@
%bcond_without curl_http2
%bcond_without lldb
Name: rust
Version: 1.52.1
Version: 1.53.0
Release: 1
Summary: The Rust Programming Language
License: (ASL 2.0 or MIT) and (BSD and MIT)
@ -30,9 +30,6 @@ Patch0009: rustc-1.51.0-disable-http2.patch
Patch0010: clippy-driver-usage-should-user-friendly.patch
Patch0011: cargo-help-clippy-should-have-description-to-user.patch
Patch0012: fix-a-println-wrong-format.patch
Patch0013: CVE-2021-29922.patch
Patch0014: fix-rustdoc-error-info.patch
Patch0015: fix-rustdoc-install-slow.patch
%{lua: function rust_triple(arch)
local abi = "gnu"
if arch == "armv7hl" then
@ -254,9 +251,6 @@ sed -i.try-python -e '/^try python3 /i try "%{python}" "$@"' ./configure
%patch0010 -p1
%patch0011 -p1
%patch0012 -p1
%patch0013 -p1
%patch0014 -p1
%patch0015 -p1
rm -rf vendor/curl-sys/curl/
rm -rf vendor/jemalloc-sys/jemalloc/
rm -rf vendor/libssh2-sys/libssh2/
@ -471,6 +465,9 @@ export %{rust_env}
%{_mandir}/man1/cargo*.1*
%changelog
* Sat Oct 02 2021 sdlzx <hdu_sdlzx@163.com> - 1.53.0-1
- Update to 1.53.0
* Tue Sep 28 2021 sdlzx <hdu_sdlzx@163.com> - 1.52.1-1
- Update to 1.52.1