mirror of
https://github.com/archlinuxarm/PKGBUILDs.git
synced 2024-11-18 22:54:00 +00:00
200 lines
6.6 KiB
Diff
200 lines
6.6 KiB
Diff
|
# https://github.com/ceph/ceph/pull/10855
|
||
|
From 518883d939f34ec0afa03aea1bac35960fb579f2 Mon Sep 17 00:00:00 2001
|
||
|
From: Loic Dachary <ldachary@redhat.com>
|
||
|
Date: Thu, 25 Aug 2016 09:09:40 +0200
|
||
|
Subject: [PATCH 1/4] Revert "common: add int64_t template for
|
||
|
strict_si_cast()"
|
||
|
|
||
|
This reverts commit e3a99c082e3ebd56d5b40d7d94d98e35629df81e.
|
||
|
---
|
||
|
src/common/strtol.cc | 2 --
|
||
|
src/test/strtol.cc | 15 ---------------
|
||
|
2 files changed, 17 deletions(-)
|
||
|
|
||
|
diff --git a/src/common/strtol.cc b/src/common/strtol.cc
|
||
|
index f43d661..50598b9 100644
|
||
|
--- a/src/common/strtol.cc
|
||
|
+++ b/src/common/strtol.cc
|
||
|
@@ -189,8 +189,6 @@ template int strict_si_cast<int>(const char *str, std::string *err);
|
||
|
|
||
|
template long long strict_si_cast<long long>(const char *str, std::string *err);
|
||
|
|
||
|
-template int64_t strict_si_cast<int64_t>(const char *str, std::string *err);
|
||
|
-
|
||
|
template uint64_t strict_si_cast<uint64_t>(const char *str, std::string *err);
|
||
|
|
||
|
uint64_t strict_sistrtoll(const char *str, std::string *err)
|
||
|
diff --git a/src/test/strtol.cc b/src/test/strtol.cc
|
||
|
index 3946736..646c055 100644
|
||
|
--- a/src/test/strtol.cc
|
||
|
+++ b/src/test/strtol.cc
|
||
|
@@ -234,21 +234,6 @@ TEST(StrictSICast, Error) {
|
||
|
(void)strict_si_cast<int>("1T", &err);
|
||
|
ASSERT_NE(err, "");
|
||
|
}
|
||
|
- {
|
||
|
- std::string err;
|
||
|
- (void)strict_si_cast<int64_t>("2E", &err);
|
||
|
- ASSERT_EQ(err, "");
|
||
|
- }
|
||
|
- {
|
||
|
- std::string err;
|
||
|
- (void)strict_si_cast<int64_t>("-2E", &err);
|
||
|
- ASSERT_EQ(err, "");
|
||
|
- }
|
||
|
- {
|
||
|
- std::string err;
|
||
|
- (void)strict_si_cast<int64_t>("1T", &err);
|
||
|
- ASSERT_EQ(err, "");
|
||
|
- }
|
||
|
}
|
||
|
|
||
|
/*
|
||
|
|
||
|
From f7cd28460147530cfd265a593b32d02adb93abe6 Mon Sep 17 00:00:00 2001
|
||
|
From: Kefu Chai <tchaikov@gmail.com>
|
||
|
Date: Sat, 30 Apr 2016 18:31:37 +0800
|
||
|
Subject: [PATCH 2/4] common/config: cast OPT_U32 options using uint32_t
|
||
|
|
||
|
the OPT_U32 options was translated using strict_si_cast<int>(), and then
|
||
|
cast the converted result to uint32_t. this could cause integer
|
||
|
underflow. we could have lifted the burden of checking invalid input
|
||
|
from the user of this option to the strict_si_cast<>() function. so in
|
||
|
this change, we use strict_si_cast<uint32_t>() instead, before casting
|
||
|
the converted value into `uint32_t`.
|
||
|
|
||
|
Signed-off-by: Kefu Chai <tchaikov@gmail.com>
|
||
|
(cherry picked from commit b7babd6aa671d688eef0af61ca17fd11eec22773)
|
||
|
---
|
||
|
src/common/config.cc | 2 +-
|
||
|
src/common/strtol.cc | 3 +--
|
||
|
2 files changed, 2 insertions(+), 3 deletions(-)
|
||
|
|
||
|
diff --git a/src/common/config.cc b/src/common/config.cc
|
||
|
index 622e237..d27bfbf 100644
|
||
|
--- a/src/common/config.cc
|
||
|
+++ b/src/common/config.cc
|
||
|
@@ -994,7 +994,7 @@ int md_config_t::set_val_raw(const char *val, const config_option *opt)
|
||
|
return 0;
|
||
|
case OPT_U32: {
|
||
|
std::string err;
|
||
|
- int f = strict_si_cast<int>(val, &err);
|
||
|
+ int f = strict_si_cast<uint32_t>(val, &err);
|
||
|
if (!err.empty())
|
||
|
return -EINVAL;
|
||
|
*(uint32_t*)opt->conf_ptr(this) = f;
|
||
|
diff --git a/src/common/strtol.cc b/src/common/strtol.cc
|
||
|
index 50598b9..bc5ccc7 100644
|
||
|
--- a/src/common/strtol.cc
|
||
|
+++ b/src/common/strtol.cc
|
||
|
@@ -186,10 +186,9 @@ T strict_si_cast(const char *str, std::string *err)
|
||
|
}
|
||
|
|
||
|
template int strict_si_cast<int>(const char *str, std::string *err);
|
||
|
-
|
||
|
template long long strict_si_cast<long long>(const char *str, std::string *err);
|
||
|
-
|
||
|
template uint64_t strict_si_cast<uint64_t>(const char *str, std::string *err);
|
||
|
+template uint32_t strict_si_cast<uint32_t>(const char *str, std::string *err);
|
||
|
|
||
|
uint64_t strict_sistrtoll(const char *str, std::string *err)
|
||
|
{
|
||
|
|
||
|
From d93eda88048d2bcefe4be3ea0aaa6ca0289eabbf Mon Sep 17 00:00:00 2001
|
||
|
From: Vikhyat Umrao <vumrao@redhat.com>
|
||
|
Date: Thu, 26 May 2016 23:30:25 +0530
|
||
|
Subject: [PATCH 3/4] common: add int64_t template for strict_si_cast()
|
||
|
|
||
|
Signed-off-by: Vikhyat Umrao <vumrao@redhat.com>
|
||
|
(cherry picked from commit 8e429d05370fbe7935212d0ae9608e7547f39860)
|
||
|
---
|
||
|
src/common/strtol.cc | 1 +
|
||
|
src/test/strtol.cc | 15 +++++++++++++++
|
||
|
2 files changed, 16 insertions(+)
|
||
|
|
||
|
diff --git a/src/common/strtol.cc b/src/common/strtol.cc
|
||
|
index bc5ccc7..0e7ea7d 100644
|
||
|
--- a/src/common/strtol.cc
|
||
|
+++ b/src/common/strtol.cc
|
||
|
@@ -187,6 +187,7 @@ T strict_si_cast(const char *str, std::string *err)
|
||
|
|
||
|
template int strict_si_cast<int>(const char *str, std::string *err);
|
||
|
template long long strict_si_cast<long long>(const char *str, std::string *err);
|
||
|
+template int64_t strict_si_cast<int64_t>(const char *str, std::string *err);
|
||
|
template uint64_t strict_si_cast<uint64_t>(const char *str, std::string *err);
|
||
|
template uint32_t strict_si_cast<uint32_t>(const char *str, std::string *err);
|
||
|
|
||
|
diff --git a/src/test/strtol.cc b/src/test/strtol.cc
|
||
|
index 646c055..3946736 100644
|
||
|
--- a/src/test/strtol.cc
|
||
|
+++ b/src/test/strtol.cc
|
||
|
@@ -234,6 +234,21 @@ TEST(StrictSICast, Error) {
|
||
|
(void)strict_si_cast<int>("1T", &err);
|
||
|
ASSERT_NE(err, "");
|
||
|
}
|
||
|
+ {
|
||
|
+ std::string err;
|
||
|
+ (void)strict_si_cast<int64_t>("2E", &err);
|
||
|
+ ASSERT_EQ(err, "");
|
||
|
+ }
|
||
|
+ {
|
||
|
+ std::string err;
|
||
|
+ (void)strict_si_cast<int64_t>("-2E", &err);
|
||
|
+ ASSERT_EQ(err, "");
|
||
|
+ }
|
||
|
+ {
|
||
|
+ std::string err;
|
||
|
+ (void)strict_si_cast<int64_t>("1T", &err);
|
||
|
+ ASSERT_EQ(err, "");
|
||
|
+ }
|
||
|
}
|
||
|
|
||
|
/*
|
||
|
|
||
|
From 117aa35094c059dbf5770b01ac13a583471e54aa Mon Sep 17 00:00:00 2001
|
||
|
From: Kefu Chai <kchai@redhat.com>
|
||
|
Date: Sun, 26 Jun 2016 01:02:03 +0800
|
||
|
Subject: [PATCH 4/4] common: instantiate strict_si_cast<long> not
|
||
|
strict_si_cast<int64_t>
|
||
|
|
||
|
this fixes the build on armf.
|
||
|
|
||
|
on 32bit platforms, cstdint is very likely to
|
||
|
|
||
|
typedef long long int int64_t;
|
||
|
|
||
|
this results in compilation error like
|
||
|
|
||
|
`common/strtol.cc:190:75: error: duplicate explicit instantiation of 'T
|
||
|
strict_si_cast(const char, std::string) [with T = long long int;
|
||
|
std::string = std::basic_string]'
|
||
|
|
||
|
[-fpermissive]
|
||
|
template int64_t strict_si_cast(const char *str, std::string *err);
|
||
|
^`
|
||
|
|
||
|
we can address this by instantiate the primitive type of `long long`
|
||
|
instead of `in64_t`.
|
||
|
|
||
|
Fixes: http://tracker.ceph.com/issues/16398
|
||
|
Signed-off-by: Kefu Chai <kchai@redhat.com>
|
||
|
(cherry picked from commit 31db4c5f9f725e13e38f3c90744e299e023d02a4)
|
||
|
---
|
||
|
src/common/strtol.cc | 2 +-
|
||
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
||
|
|
||
|
diff --git a/src/common/strtol.cc b/src/common/strtol.cc
|
||
|
index 0e7ea7d..321521d 100644
|
||
|
--- a/src/common/strtol.cc
|
||
|
+++ b/src/common/strtol.cc
|
||
|
@@ -186,8 +186,8 @@ T strict_si_cast(const char *str, std::string *err)
|
||
|
}
|
||
|
|
||
|
template int strict_si_cast<int>(const char *str, std::string *err);
|
||
|
+template long strict_si_cast<long>(const char *str, std::string *err);
|
||
|
template long long strict_si_cast<long long>(const char *str, std::string *err);
|
||
|
-template int64_t strict_si_cast<int64_t>(const char *str, std::string *err);
|
||
|
template uint64_t strict_si_cast<uint64_t>(const char *str, std::string *err);
|
||
|
template uint32_t strict_si_cast<uint32_t>(const char *str, std::string *err);
|
||
|
|