Skip to content

Commit 5c176f3

Browse files
author
Thomas Goodwin
committed
Fix unsafe return for ossie::badConversion::what()
The return value of "c_str()" does not outlive the temporary string or stringstream, which go out of scope at the function return. Although it's no longer needed, the overload of "what()" remains to ensure ABI compatibility. (see Geontech/core-framework@3ef4cd3) Signed-off-by: Thomas Goodwin <btgoodwin@geontech.com>
1 parent b3a6919 commit 5c176f3

2 files changed

Lines changed: 40 additions & 0 deletions

File tree

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
Index: src/base/include/ossie/prop_helpers.h
2+
===================================================================
3+
--- src.orig/base/include/ossie/prop_helpers.h
4+
+++ src/base/include/ossie/prop_helpers.h
5+
@@ -84,15 +84,28 @@ namespace ossie
6+
7+
class badConversion : public std::runtime_error {
8+
public:
9+
- badConversion(std::string value, std::string type) : std::runtime_error("Unable to perform conversion"), _value(value), _type(type) {};
10+
- ~badConversion() throw() {};
11+
+ badConversion(std::string value, std::string type) :
12+
+ std::runtime_error(badConversion::error_message(value, type)),
13+
+ _value(value),
14+
+ _type(type)
15+
+ {
16+
+ }
17+
+
18+
+ ~badConversion() throw() {}
19+
+
20+
virtual const char* what() const throw()
21+
{
22+
- std::ostringstream _msg;
23+
- _msg << std::runtime_error::what() << ": '"<<_value<<"' to type '"<<_type << "'";
24+
- return _msg.str().c_str();
25+
- };
26+
+ // This function is preserved to keep the vtable the same, but can
27+
+ // be removed when ABI compatibility is not a concern.
28+
+ return std::runtime_error::what();
29+
+ }
30+
private:
31+
+ static std::string error_message(const std::string& value, const std::string& type)
32+
+ {
33+
+ std::ostringstream msg;
34+
+ msg << "Unable to perform conversion: '" << value << "' to type '" << type << "'";
35+
+ return msg.str();
36+
+ }
37+
std::string _value, _type;
38+
};
39+

recipes-core/core-framework/redhawk_2.2.3.bb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ SRC_URI_append = "\
6666
file://dlopen_reverse_order.patch \
6767
file://bare-python2-references.patch \
6868
file://filesystem_impl-const-value.patch \
69+
file://prop_helpers-bad-conversion.patch \
6970
"
7071

7172
S = "${WORKDIR}/git/redhawk/src"

0 commit comments

Comments
 (0)