haubi 19/05/22 15:36:29
Added: 016_all_nothreads.patch
017_all_orbcache_refcount.patch
018_all_catch_by_ref.patch
019_all_discriminator-init.patch
020_all_unsignedbits.patch
021_all_strict-aliasing.patch
022_all_potential-buffer-overflow.patch
023_all_formatstrings.patch
024_all_gcc8-warnings.patch
Log:
new patch, for upstream darcs repo and gcc-8
Revision Changes Path
1.1 src/patchsets/mico/9999/016_all_nothreads.patch
file :
http://sources.gentoo.org/viewvc.cgi/gentoo/src/patchsets/mico/9999/016_all_nothreads.patch?rev=1.1&view=markup
plain:
http://sources.gentoo.org/viewvc.cgi/gentoo/src/patchsets/mico/9999/016_all_nothreads.patch?rev=1.1&content-type=text/plain
Index: 016_all_nothreads.patch
===================================================================
>From 602df93bd312f97777e32de2a1a5400f7c8e53ae Mon Sep 17 00:00:00 2001
From: Michael Haubenwallner <[email protected]>
Date: Wed, 22 May 2019 16:08:46 +0200
Subject: [PATCH 01/19] fix compilation with threads disabled
Adjust #ifdef HAVE_THREADS for when not defined.
---
orb/iop.cc | 4 ++--
orb/orb.cc | 6 ++++++
orb/ssl.cc | 2 +-
orb/util.cc | 36 ++++++++++++++++++++++++++++++------
4 files changed, 39 insertions(+), 9 deletions(-)
diff --git a/orb/iop.cc b/orb/iop.cc
index fd5220a..f9fdd89 100644
--- a/orb/iop.cc
+++ b/orb/iop.cc
@@ -5931,8 +5931,8 @@ MICO::IIOPServer::handle_invoke_request (GIOPConn *conn,
GIOPInContext &in)
CORBA::Boolean resp;
CORBA::ORBRequest* req;
CORBA::Principal_ptr pr = conn->transport()->get_principal();
-#ifdef HAVE_THREADS
CORBA::Object_ptr obj = CORBA::Object::_nil();
+#ifdef HAVE_THREADS
if (MICO::MTManager::thread_per_connection()) {
CORBA::Object_ptr throbj = static_cast<CORBA::Object*>
(MICOMT::Thread::get_specific(MICO::IIOPServer::target_obj_key_));
@@ -6015,8 +6015,8 @@ MICO::IIOPServer::handle_locate_request (GIOPConn *conn,
GIOPInContext &in)
{
CORBA::ULong req_id;
//CORBA::Object_ptr obj = new CORBA::Object (new CORBA::IOR);
-#ifdef HAVE_THREADS
CORBA::Object_ptr obj = CORBA::Object::_nil();
+#ifdef HAVE_THREADS
if (MICO::MTManager::thread_per_connection()) {
CORBA::Object_ptr throbj = static_cast<CORBA::Object*>
(MICOMT::Thread::get_specific(MICO::IIOPServer::target_obj_key_));
diff --git a/orb/orb.cc b/orb/orb.cc
index af85775..638aae5 100644
--- a/orb/orb.cc
+++ b/orb/orb.cc
@@ -207,9 +207,11 @@ CORBA::ORBInvokeRec::init_invoke (ORB_ptr orb,
_cb = callback;
_cb_async_callback = FALSE;
if (_cb != NULL) {
+#ifdef HAVE_THREADS
if (dynamic_cast<ORBAsyncCallback*>(_cb) != NULL) {
_cb_async_callback = TRUE;
}
+#endif
}
_active = TRUE;
#ifdef USE_MESSAGING
@@ -273,11 +275,13 @@ CORBA::ORBInvokeRec::init_bind (ORB_ptr orb, const char
*repo,
_adapter = oa;
_cb = callback;
_cb_async_callback = FALSE;
+#ifdef HAVE_THREADS
if (_cb != NULL) {
if (dynamic_cast<ORBAsyncCallback*>(_cb) != NULL) {
_cb_async_callback = TRUE;
}
}
+#endif
_objtag = tag;
_active = TRUE;
}
@@ -299,11 +303,13 @@ CORBA::ORBInvokeRec::init_locate (ORB_ptr orb, Object_ptr
o,
_adapter = oa;
_cb = callback;
_cb_async_callback = FALSE;
+#ifdef HAVE_THREADS
if (_cb != NULL) {
if (dynamic_cast<ORBAsyncCallback*>(_cb) != NULL) {
_cb_async_callback = TRUE;
}
}
+#endif
_active = TRUE;
}
diff --git a/orb/ssl.cc b/orb/ssl.cc
index 3b92614..2a7404f 100644
--- a/orb/ssl.cc
+++ b/orb/ssl.cc
@@ -1096,8 +1096,8 @@ MICOSSL::SSLTransport::isreadable ()
CORBA::Long
MICOSSL::SSLTransport::read (void *_b, CORBA::Long len)
{
-#ifdef HAVE_THREADS
int i = -1;
+#ifdef HAVE_THREADS
// We can't lock while using blocking transport (blocking is used only
// by thread per connection concurrency model) because it block on read
// and it can lead to deadlock ie. reader will be faster then writer,
diff --git a/orb/util.cc b/orb/util.cc
index 1be2b2a..b52527d 100644
--- a/orb/util.cc
+++ b/orb/util.cc
@@ -1328,13 +1328,21 @@ mico_float2ieee (CORBA::Octet ieee[4], CORBA::Float f)
void
mico_print_stack_trace()
{
- cerr << getpid() << "|" << MICOMT::Thread::self() << ": Stack trace:" <<
endl;
+ cerr << getpid()
+#ifdef HAVE_THREADS
+ << "|" << MICOMT::Thread::self()
+#endif // HAVE_THREADS
+ << ": Stack trace:" << endl;
const int max_length = 500;
void* array[max_length];
size_t size = backtrace(array, max_length);
char** strings = backtrace_symbols(array, size);
for (size_t i = 0; i < size; i++) {
- cerr << getpid() << "|" << MICOMT::Thread::self() << " " <<
strings[i] << endl;
+ cerr << getpid()
+#ifdef HAVE_THREADS
+ << "|" << MICOMT::Thread::self()
+#endif // HAVE_THREADS
+ << " " << strings[i] << endl;
}
free (strings);
}
@@ -1342,13 +1350,21 @@ mico_print_stack_trace()
void
mico_print_stack_trace(ostream& out)
{
- out << getpid() << "|" << MICOMT::Thread::self() << ": Stack trace:" <<
endl;
+ out << getpid()
+#ifdef HAVE_THREADS
+ << "|" << MICOMT::Thread::self()
+#endif // HAVE_THREADS
+ << ": Stack trace:" << endl;
const int max_length = 500;
void* array[max_length];
size_t size = backtrace(array, max_length);
char** strings = backtrace_symbols(array, size);
for (size_t i = 0; i < size; i++) {
- out << getpid() << "|" << MICOMT::Thread::self() << " " <<
strings[i] << endl;
+ out << getpid()
+#ifdef HAVE_THREADS
+ << "|" << MICOMT::Thread::self()
+#endif // HAVE_THREADS
+ << " " << strings[i] << endl;
}
free (strings);
}
@@ -1369,9 +1385,17 @@ mico_print_stack_trace(const char* s)
}
}
if (found == 1) {
- cerr << getpid() << "|" << MICOMT::Thread::self() << ": Stack trace:"
<< endl;
+ cerr << getpid()
+#ifdef HAVE_THREADS
+ << "|" << MICOMT::Thread::self()
+#endif // HAVE_THREADS
+ << ": Stack trace:" << endl;
for (size_t i = 0; i < size; i++) {
- cerr << getpid() << "|" << MICOMT::Thread::self() << " " <<
strings[i] << endl;
+ cerr << getpid()
+#ifdef HAVE_THREADS
+ << "|" << MICOMT::Thread::self()
+#endif // HAVE_THREADS
+ << " " << strings[i] << endl;
}
}
free (strings);
--
2.19.2
1.1 src/patchsets/mico/9999/017_all_orbcache_refcount.patch
file :
http://sources.gentoo.org/viewvc.cgi/gentoo/src/patchsets/mico/9999/017_all_orbcache_refcount.patch?rev=1.1&view=markup
plain:
http://sources.gentoo.org/viewvc.cgi/gentoo/src/patchsets/mico/9999/017_all_orbcache_refcount.patch?rev=1.1&content-type=text/plain
Index: 017_all_orbcache_refcount.patch
===================================================================
>From 2c12b28fb6b310b15a828327c68f51cbc6ff17af Mon Sep 17 00:00:00 2001
From: Michael Haubenwallner <[email protected]>
Date: Wed, 22 May 2019 16:11:26 +0200
Subject: [PATCH 02/19] fix core dump with threads disabled
When caching the ORBInvokeRec object, which does happen when threads are
disabled, we need to respect the reference count of ORBInvokeRec.
Otherwise, the idl compiler dumps core when built with optimization,
and valgrind does report invalid memory read after free.
---
include/mico/orb_mico.h | 2 +-
orb/orb.cc | 11 ++++++-----
2 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/include/mico/orb_mico.h b/include/mico/orb_mico.h
index 1cc936b..4dc0b23 100644
--- a/include/mico/orb_mico.h
+++ b/include/mico/orb_mico.h
@@ -307,7 +307,7 @@ private:
OctetSeq _terminal_id;
#ifdef USE_ORB_CACHE
- ORBInvokeRec *_cache_rec;
+ ORBInvokeRec_var _cache_rec;
CORBA::Boolean _cache_used;
#endif
typedef std::map<std::string, bool> OptionMap;
diff --git a/orb/orb.cc b/orb/orb.cc
index 638aae5..4ef2804 100644
--- a/orb/orb.cc
+++ b/orb/orb.cc
@@ -727,8 +727,8 @@ CORBA::ORB::ORB (int &argc, char **argv, const char *rcfile)
CORBA::ORB::~ORB ()
{
#ifdef USE_ORB_CACHE
- if (_cache_used && _cache_rec != NULL)
- delete _cache_rec;
+ _cache_used = FALSE;
+ _cache_rec = NULL;
#endif
assert(this->_disp != NULL);
delete _disp;
@@ -2369,7 +2369,7 @@ CORBA::ORB::create_invoke (MsgId msgid)
if (!_cache_used) {
_cache_used = TRUE;
_cache_rec = new ORBInvokeRec(msgid);
- return _cache_rec;
+ return ORBInvokeRec::_duplicate(_cache_rec);
}
#endif
return new ORBInvokeRec(msgid);
@@ -2416,7 +2416,7 @@ CORBA::ORB::get_invoke (MsgId id)
{
#ifdef USE_ORB_CACHE
if (_cache_used && _cache_rec->id() == id && _cache_rec->active() )
- return _cache_rec;
+ return CORBA::ORBInvokeRec::_duplicate(_cache_rec);
#endif
if (MICO::Logger::IsLogged (MICO::Logger::ORB)) {
@@ -2464,7 +2464,7 @@ CORBA::ORB::del_invoke (MsgId id)
{
#ifdef USE_ORB_CACHE
if (_cache_used && _cache_rec->id() == id) {
- delete _cache_rec;
+ _cache_rec = NULL;
_cache_used = FALSE;
return;
}
@@ -2835,6 +2835,7 @@ CORBA::ORB::invoke_async (Object_ptr obj,
#ifdef USE_ORB_CACHE
if (_cache_used && _cache_rec == rec) {
_cache_used = FALSE;
+ _cache_rec = NULL;
}
#endif
//delete rec;
--
2.19.2
1.1 src/patchsets/mico/9999/018_all_catch_by_ref.patch
file :
http://sources.gentoo.org/viewvc.cgi/gentoo/src/patchsets/mico/9999/018_all_catch_by_ref.patch?rev=1.1&view=markup
plain:
http://sources.gentoo.org/viewvc.cgi/gentoo/src/patchsets/mico/9999/018_all_catch_by_ref.patch?rev=1.1&content-type=text/plain
Index: 018_all_catch_by_ref.patch
===================================================================
>From c9a15bb60dca7077aaba25d8612f67d28542d301 Mon Sep 17 00:00:00 2001
From: Michael Haubenwallner <[email protected]>
Date: Wed, 22 May 2019 10:48:39 +0200
Subject: [PATCH 04/19] catch polymorphic exceptions by reference
gcc-8 emits a warning when catching polymorphic exceptions by value
---
orb/iop.cc | 4 ++--
orb/security/transportsecurity_impl.cc | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/orb/iop.cc b/orb/iop.cc
index f9fdd89..60cd868 100644
--- a/orb/iop.cc
+++ b/orb/iop.cc
@@ -3881,7 +3881,7 @@ MICO::IIOPProxy::make_conn (CORBA::Object_ptr obj,
CORBA::Boolean& timedout)
} catch (CORBA::BAD_PARAM&) {
// this is thrown by MICO and CORBA 2.2. It seems MICO
// is not compliant here with CORBA 2.3.
- } catch (CORBA::SystemException) {
+ } catch (CORBA::SystemException&) {
// CORBA 2.3 and highers might throw either INV_POLICY
// or BAD_INV_ORDER exceptions
}
@@ -3893,7 +3893,7 @@ MICO::IIOPProxy::make_conn (CORBA::Object_ptr obj,
CORBA::Boolean& timedout)
} catch (CORBA::BAD_PARAM&) {
// this is thrown by MICO and CORBA 2.2. It seems MICO
// is not compliant here with CORBA 2.3.
- } catch (CORBA::SystemException) {
+ } catch (CORBA::SystemException&) {
// CORBA 2.3 and highers might throw either INV_POLICY
// or BAD_INV_ORDER exceptions
}
diff --git a/orb/security/transportsecurity_impl.cc
b/orb/security/transportsecurity_impl.cc
index 1449f7f..4391617 100644
--- a/orb/security/transportsecurity_impl.cc
+++ b/orb/security/transportsecurity_impl.cc
@@ -879,7 +879,7 @@
MICOSL3_TransportSecurity::CredentialsCurator_impl::get_target_credentials
} catch (CORBA::BAD_PARAM&) {
// this is thrown by MICO and CORBA 2.2. It seems MICO
// is not compliant here with CORBA 2.3.
- } catch (CORBA::SystemException) {
+ } catch (CORBA::SystemException&) {
// CORBA 2.3 and highers might throw either INV_POLICY
// or BAD_INV_ORDER exceptions
}
@@ -891,7 +891,7 @@
MICOSL3_TransportSecurity::CredentialsCurator_impl::get_target_credentials
} catch (CORBA::BAD_PARAM&) {
// this is thrown by MICO and CORBA 2.2. It seems MICO
// is not compliant here with CORBA 2.3.
- } catch (CORBA::SystemException) {
+ } catch (CORBA::SystemException&) {
// CORBA 2.3 and highers might throw either INV_POLICY
// or BAD_INV_ORDER exceptions
}
--
2.19.2
1.1 src/patchsets/mico/9999/019_all_discriminator-init.patch
file :
http://sources.gentoo.org/viewvc.cgi/gentoo/src/patchsets/mico/9999/019_all_discriminator-init.patch?rev=1.1&view=markup
plain:
http://sources.gentoo.org/viewvc.cgi/gentoo/src/patchsets/mico/9999/019_all_discriminator-init.patch?rev=1.1&content-type=text/plain
Index: 019_all_discriminator-init.patch
===================================================================
>From 788aca8e2665ca9f2a00de5a2dcf2c0357b9b023 Mon Sep 17 00:00:00 2001
From: Michael Haubenwallner <[email protected]>
Date: Wed, 22 May 2019 14:36:12 +0200
Subject: [PATCH 03/19] fix uninitialized discriminator values
Plain old data types lack a constructor for default initialization, and
valgrind does detect them uninitialized in the idl compiler for example.
---
include/mico/security/csi.h | 4 ++--
orb/security/csi.cc | 6 ++++--
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/include/mico/security/csi.h b/include/mico/security/csi.h
index ab66c69..7b9cfec 100644
--- a/include/mico/security/csi.h
+++ b/include/mico/security/csi.h
@@ -154,8 +154,8 @@ class IdentityToken {
} _m;
public:
- #ifdef HAVE_EXPLICIT_STRUCT_OPS
IdentityToken();
+ #ifdef HAVE_EXPLICIT_STRUCT_OPS
~IdentityToken();
IdentityToken( const IdentityToken& s );
IdentityToken& operator=( const IdentityToken& s );
@@ -304,8 +304,8 @@ class SASContextBody {
} _m;
public:
- #ifdef HAVE_EXPLICIT_STRUCT_OPS
SASContextBody();
+ #ifdef HAVE_EXPLICIT_STRUCT_OPS
~SASContextBody();
SASContextBody( const SASContextBody& s );
SASContextBody& operator=( const SASContextBody& s );
diff --git a/orb/security/csi.cc b/orb/security/csi.cc
index ce3d92e..700da59 100644
--- a/orb/security/csi.cc
+++ b/orb/security/csi.cc
@@ -193,11 +193,12 @@ namespace CSI
CORBA::TypeCodeConst _tc_IdentityToken;
}
-#ifdef HAVE_EXPLICIT_STRUCT_OPS
CSI::IdentityToken::IdentityToken()
+ : _discriminator(ITTAbsent)
{
}
+#ifdef HAVE_EXPLICIT_STRUCT_OPS
CSI::IdentityToken::IdentityToken( const IdentityToken&_u )
{
_discriminator = _u._discriminator;
@@ -904,11 +905,12 @@ namespace CSI
CORBA::TypeCodeConst _tc_SASContextBody;
}
-#ifdef HAVE_EXPLICIT_STRUCT_OPS
CSI::SASContextBody::SASContextBody()
+ : _discriminator(MTEstablishContext)
{
}
+#ifdef HAVE_EXPLICIT_STRUCT_OPS
CSI::SASContextBody::SASContextBody( const SASContextBody&_u )
{
_discriminator = _u._discriminator;
--
2.19.2
1.1 src/patchsets/mico/9999/020_all_unsignedbits.patch
file :
http://sources.gentoo.org/viewvc.cgi/gentoo/src/patchsets/mico/9999/020_all_unsignedbits.patch?rev=1.1&view=markup
plain:
http://sources.gentoo.org/viewvc.cgi/gentoo/src/patchsets/mico/9999/020_all_unsignedbits.patch?rev=1.1&content-type=text/plain
Index: 020_all_unsignedbits.patch
===================================================================
>From ac419720dbb2e7abf7348a58fba0121ee2221219 Mon Sep 17 00:00:00 2001
From: Michael Haubenwallner <[email protected]>
Date: Wed, 22 May 2019 15:07:13 +0200
Subject: [PATCH 15/19] bits datatypes need to be unsigned
otherwise, with gcc-8 we get this error:
uni_fromuni.cc:554:16: error: narrowing conversion of '4026531840' from
'unsigned int' to 'bits32' {aka 'long int'} inside { } [-Wnarrowing]
0xF0000000 };
Also, the bits32 datatype needs to be int, as long may be 64bit.
---
orb/uni_types.h | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/orb/uni_types.h b/orb/uni_types.h
index a2f4fbd..50e70d0 100644
--- a/orb/uni_types.h
+++ b/orb/uni_types.h
@@ -40,15 +40,15 @@
#include <sys/types.h>
#endif
-typedef char bits8;
-typedef short bits16;
-typedef long bits32;
+typedef unsigned char bits8;
+typedef unsigned short bits16;
+typedef unsigned int bits32;
#if defined(_WIN32) && !defined(__MINGW32__)
-typedef __int64 bits64;
+typedef unsigned __int64 bits64;
#elif defined (_POCKET_PC)
-typedef __int64 bits64;
+typedef unsigned __int64 bits64;
#else
-typedef long long bits64;
+typedef unsigned long long bits64;
#endif
typedef char uni_byte;
--
2.19.2
1.1 src/patchsets/mico/9999/021_all_strict-aliasing.patch
file :
http://sources.gentoo.org/viewvc.cgi/gentoo/src/patchsets/mico/9999/021_all_strict-aliasing.patch?rev=1.1&view=markup
plain:
http://sources.gentoo.org/viewvc.cgi/gentoo/src/patchsets/mico/9999/021_all_strict-aliasing.patch?rev=1.1&content-type=text/plain
Index: 021_all_strict-aliasing.patch
===================================================================
>From a4fc7e6df8b720ab1715efc291b14248aa4f8b6d Mon Sep 17 00:00:00 2001
From: Michael Haubenwallner <[email protected]>
Date: Wed, 22 May 2019 15:14:20 +0200
Subject: [PATCH 16/19] fix 'will break strict aliasing' warnings
casting pointers between other than void* and char* may break when
optimization is enabled, and gcc-8 does emit warnings like:
buffer.cc:353:21: warning: dereferencing type-punned pointer will break
strict-aliasing rules [-Wstrict-aliasing]
*((CORBA::Short *&)b)++ = *(const CORBA::Short *)p;
---
orb/buffer.cc | 142 +++++++++++++++++++++++++++++++++-----------------
orb/ssl.cc | 18 ++++---
2 files changed, 105 insertions(+), 55 deletions(-)
diff --git a/orb/buffer.cc b/orb/buffer.cc
index bcfee18..de6735d 100644
--- a/orb/buffer.cc
+++ b/orb/buffer.cc
@@ -348,14 +348,26 @@ CORBA::Buffer::put2 (const void *p)
// assert (((_wptr - _walignbase) % 2) == 0);
assert (!_readonly && _wptr >= _walignbase);
resize (2);
- CORBA::Octet *b = _buf + _wptr;
- if (!(((long)b | (long)p)&1)) {
- *((CORBA::Short *&)b)++ = *(const CORBA::Short *)p;
+ union {
+ const CORBA::Short *shortPtr;
+ const CORBA::Octet *octetPtr;
+ const void *voidPtr;
+ uintptr_t uintPtr;
+ } in;
+ in.voidPtr = p;
+ union {
+ CORBA::Short *shortPtr;
+ CORBA::Octet *octetPtr;
+ uintptr_t uintPtr;
+ } out;
+ out.octetPtr = _buf + _wptr;
+ if (!((out.uintPtr | in.uintPtr)&1)) {
+ *out.shortPtr++ = *in.shortPtr;
} else {
- *b++ = *((const Octet * &)p)++;
- *b++ = *(const Octet *)p;
+ *out.octetPtr++ = *in.octetPtr++;
+ *out.octetPtr++ = *in.octetPtr;
}
- size_t t = b - _buf;
+ size_t t = out.octetPtr - _buf;
assert(t < UINT_MAX);
_wptr = (ULong)t;
}
@@ -366,16 +378,28 @@ CORBA::Buffer::put4 (const void *p)
// assert (((_wptr - _walignbase) % 4) == 0);
assert (!_readonly && _wptr >= _walignbase);
resize (4);
- CORBA::Octet *b = _buf + _wptr;
- if (!(((long)b | (long)p)&3)) {
- *((CORBA::Long * &)b)++ = *(const CORBA::Long *)p;
+ union {
+ const CORBA::Long *longPtr;
+ const CORBA::Octet *octetPtr;
+ const void *voidPtr;
+ uintptr_t uintPtr;
+ } in;
+ in.voidPtr = p;
+ union {
+ CORBA::Long *longPtr;
+ CORBA::Octet *octetPtr;
+ uintptr_t uintPtr;
+ } out;
+ out.octetPtr = _buf + _wptr;
+ if (!((out.uintPtr | in.uintPtr)&3)) {
+ *out.longPtr++ = *in.longPtr;
} else {
- *b++ = *((const Octet * &)p)++;
- *b++ = *((const Octet * &)p)++;
- *b++ = *((const Octet * &)p)++;
- *b++ = *(const Octet *)p;
+ *out.octetPtr++ = *in.octetPtr++;
+ *out.octetPtr++ = *in.octetPtr++;
+ *out.octetPtr++ = *in.octetPtr++;
+ *out.octetPtr++ = *in.octetPtr;
}
- size_t t = b - _buf;
+ size_t t = out.octetPtr - _buf;
assert(t < UINT_MAX);
_wptr = (ULong)t;
}
@@ -386,20 +410,32 @@ CORBA::Buffer::put8 (const void *p)
// assert (((_wptr - _walignbase) % 8) == 0);
assert (!_readonly && _wptr >= _walignbase);
resize (8);
- CORBA::Octet *b = _buf + _wptr;
- if (!(((long)b | (long)p)&7)) {
- *((CORBA::LongLong *&)b)++ = *(const CORBA::LongLong *)p;
+ union {
+ const CORBA::LongLong *longlongPtr;
+ const CORBA::Octet *octetPtr;
+ const void *voidPtr;
+ uintptr_t uintPtr;
+ } in;
+ in.voidPtr = p;
+ union {
+ CORBA::LongLong *longlongPtr;
+ CORBA::Octet *octetPtr;
+ uintptr_t uintPtr;
+ } out;
+ out.octetPtr = _buf + _wptr;
+ if (!((out.uintPtr | in.uintPtr)&7)) {
+ *out.longlongPtr++ = *in.longlongPtr;
} else {
- *b++ = *((const Octet * &)p)++;
- *b++ = *((const Octet * &)p)++;
- *b++ = *((const Octet * &)p)++;
- *b++ = *((const Octet * &)p)++;
- *b++ = *((const Octet * &)p)++;
- *b++ = *((const Octet * &)p)++;
- *b++ = *((const Octet * &)p)++;
- *b++ = *(const Octet *)p;
+ *out.octetPtr++ = *in.octetPtr++;
+ *out.octetPtr++ = *in.octetPtr++;
+ *out.octetPtr++ = *in.octetPtr++;
+ *out.octetPtr++ = *in.octetPtr++;
+ *out.octetPtr++ = *in.octetPtr++;
+ *out.octetPtr++ = *in.octetPtr++;
+ *out.octetPtr++ = *in.octetPtr++;
+ *out.octetPtr++ = *in.octetPtr;
}
- size_t t = b - _buf;
+ size_t t = out.octetPtr - _buf;
assert(t < UINT_MAX);
_wptr = (ULong)t;
}
@@ -411,29 +447,41 @@ CORBA::Buffer::put16 (const void *p)
// assert (((_wptr - _walignbase) % 8) == 0);
assert (!_readonly && _wptr >= _walignbase);
resize (16);
- CORBA::Octet *b = _buf + _wptr;
- if (!(((long)b | (long)p)&7)) {
- *((CORBA::LongLong *&)b)++ = *((const CORBA::LongLong * &)p)++;
- *((CORBA::LongLong *&)b)++ = *(const CORBA::LongLong *)p;
+ union {
+ const CORBA::LongLong *longlongPtr;
+ const CORBA::Octet *octetPtr;
+ const void *voidPtr;
+ uintptr_t uintPtr;
+ } in;
+ in.voidPtr = p;
+ union {
+ CORBA::LongLong *longlongPtr;
+ CORBA::Octet *octetPtr;
+ uintptr_t uintPtr;
+ } out;
+ out.octetPtr = _buf + _wptr;
+ if (!((out.uintPtr | in.uintPtr)&7)) {
+ *out.longlongPtr++ = *in.longlongPtr++;
+ *out.longlongPtr++ = *in.longlongPtr;
} else {
- *b++ = *((const Octet * &)p)++;
- *b++ = *((const Octet * &)p)++;
- *b++ = *((const Octet * &)p)++;
- *b++ = *((const Octet * &)p)++;
- *b++ = *((const Octet * &)p)++;
- *b++ = *((const Octet * &)p)++;
- *b++ = *((const Octet * &)p)++;
- *b++ = *((const Octet * &)p)++;
- *b++ = *((const Octet * &)p)++;
- *b++ = *((const Octet * &)p)++;
- *b++ = *((const Octet * &)p)++;
- *b++ = *((const Octet * &)p)++;
- *b++ = *((const Octet * &)p)++;
- *b++ = *((const Octet * &)p)++;
- *b++ = *((const Octet * &)p)++;
- *b++ = *(const Octet *)p;
+ *out.octetPtr++ = *in.octetPtr++;
+ *out.octetPtr++ = *in.octetPtr++;
+ *out.octetPtr++ = *in.octetPtr++;
+ *out.octetPtr++ = *in.octetPtr++;
+ *out.octetPtr++ = *in.octetPtr++;
+ *out.octetPtr++ = *in.octetPtr++;
+ *out.octetPtr++ = *in.octetPtr++;
+ *out.octetPtr++ = *in.octetPtr++;
+ *out.octetPtr++ = *in.octetPtr++;
+ *out.octetPtr++ = *in.octetPtr++;
+ *out.octetPtr++ = *in.octetPtr++;
+ *out.octetPtr++ = *in.octetPtr++;
+ *out.octetPtr++ = *in.octetPtr++;
+ *out.octetPtr++ = *in.octetPtr++;
+ *out.octetPtr++ = *in.octetPtr++;
+ *out.octetPtr++ = *in.octetPtr;
}
- size_t t = b - _buf;
+ size_t t = out.octetPtr - _buf;
assert(t < UINT_MAX);
_wptr = (ULong)t;
}
diff --git a/orb/ssl.cc b/orb/ssl.cc
index 2a7404f..efad2dd 100644
--- a/orb/ssl.cc
+++ b/orb/ssl.cc
@@ -1959,11 +1959,11 @@ MICOSSL::SSLComponent::encode (CORBA::DataEncoder &ec)
const
{
// MICO_SSL_VB_COMPAT ...
if (sizeof (Security::AssociationOptions) == sizeof (CORBA::ULong)) {
- ec.put_ulong ((CORBA::ULong&)_target_supports);
- ec.put_ulong ((CORBA::ULong&)_target_requires);
+ ec.put_ulong ((CORBA::ULong)_target_supports);
+ ec.put_ulong ((CORBA::ULong)_target_requires);
} else {
- ec.put_ushort ((CORBA::UShort&)_target_supports);
- ec.put_ushort ((CORBA::UShort&)_target_requires);
+ ec.put_ushort ((CORBA::UShort)_target_supports);
+ ec.put_ushort ((CORBA::UShort)_target_requires);
}
ec.put_ushort (_port);
}
@@ -2049,11 +2049,13 @@ MICOSSL::SSLComponentDecoder::decode
(CORBA::DataDecoder &dc,
{
// MICO_SSL_VB_COMPAT ...
if (sizeof (Security::AssociationOptions) == sizeof (CORBA::ULong)) {
- check (dc.get_ulong ((CORBA::ULong&)target_supports));
- check (dc.get_ulong ((CORBA::ULong&)target_requires));
+ CORBA::ULong opts;
+ check (dc.get_ulong (opts)); target_supports = opts;
+ check (dc.get_ulong (opts)); target_requires = opts;
} else {
- check (dc.get_ushort ((CORBA::UShort&)target_supports));
- check (dc.get_ushort ((CORBA::UShort&)target_requires));
+ CORBA::UShort opts;
+ check (dc.get_ushort (opts)); target_supports = opts;
+ check (dc.get_ushort (opts)); target_requires = opts;
}
check (dc.get_ushort (port));
}
--
2.19.2
1.1
src/patchsets/mico/9999/022_all_potential-buffer-overflow.patch
file :
http://sources.gentoo.org/viewvc.cgi/gentoo/src/patchsets/mico/9999/022_all_potential-buffer-overflow.patch?rev=1.1&view=markup
plain:
http://sources.gentoo.org/viewvc.cgi/gentoo/src/patchsets/mico/9999/022_all_potential-buffer-overflow.patch?rev=1.1&content-type=text/plain
Index: 022_all_potential-buffer-overflow.patch
===================================================================
>From 88474cf7ec9a778df34d26e20aa9cbb919d321bc Mon Sep 17 00:00:00 2001
From: Michael Haubenwallner <[email protected]>
Date: Wed, 22 May 2019 15:18:39 +0200
Subject: [PATCH 17/19] fix potential buffer overflow warning
gcc-8 is able to detect potential buffer overflows:
cccp.c:4083:20: warning: '%d' directive writing between 1 and 10 bytes into a
region of size 8 [-Wformat-overflow=]
sprintf (buf, "%d", true_indepth - 1);
^~
cccp.c:4083:19: note: directive argument in the range [-1, 2147483646]
sprintf (buf, "%d", true_indepth - 1);
^~~~
In file included from /usr/include/stdio.h:862,
from cccp.c:57:
/usr/include/bits/stdio2.h:33:10: note: '__builtin___sprintf_chk' output
between 2 and 11 bytes into a destination of size 8
return __builtin___sprintf_chk (__s, __USE_FORTIFY_LEVEL - 1,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
__bos (__s), __fmt, __va_arg_pack ());
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
---
cpp/cccp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/cpp/cccp.c b/cpp/cccp.c
index d40d10c..ce8007b 100644
--- a/cpp/cccp.c
+++ b/cpp/cccp.c
@@ -4079,7 +4079,7 @@ special_symbol (hp, op)
if (instack[i].fname != NULL)
true_indepth++;
- buf = (char *) alloca (8); /* Eight bytes ought to be more than enough */
+ buf = (char *) alloca (11+1); /* Maximum length for signed datatype */
sprintf (buf, "%d", true_indepth - 1);
break;
--
2.19.2
1.1 src/patchsets/mico/9999/023_all_formatstrings.patch
file :
http://sources.gentoo.org/viewvc.cgi/gentoo/src/patchsets/mico/9999/023_all_formatstrings.patch?rev=1.1&view=markup
plain:
http://sources.gentoo.org/viewvc.cgi/gentoo/src/patchsets/mico/9999/023_all_formatstrings.patch?rev=1.1&content-type=text/plain
Index: 023_all_formatstrings.patch
===================================================================
>From fb2f88851563a500ec4c21efc29b7b98f9445771 Mon Sep 17 00:00:00 2001
From: Michael Haubenwallner <[email protected]>
Date: Wed, 22 May 2019 15:26:53 +0200
Subject: [PATCH 18/19] fix format string mixing 32bit and 64bit datatypes
CORBA::Long datatype is 32bit, but C long datatype may be 64bit
---
idl/codegen-wsdl.cc | 8 ++++----
orb/uni_fromuni.cc | 2 +-
orb/uni_touni.cc | 2 +-
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/idl/codegen-wsdl.cc b/idl/codegen-wsdl.cc
index 2753ce8..071b03c 100644
--- a/idl/codegen-wsdl.cc
+++ b/idl/codegen-wsdl.cc
@@ -934,7 +934,7 @@ CodeGenWSDL::Identifier
CodeGenWSDL::getTypename(CORBA::IDLType_ptr type, bool p
{
CORBA::StringDef_ptr s =
CORBA::StringDef::_narrow(type);
- sprintf(&buf[0], "%sCORBA.string_%lu",
+ sprintf(&buf[0], "%sCORBA.string_%u",
prefix?"tns:":"",
s->bound());
return &buf[0];
@@ -945,7 +945,7 @@ CodeGenWSDL::Identifier
CodeGenWSDL::getTypename(CORBA::IDLType_ptr type, bool p
{
CORBA::WstringDef_ptr s =
CORBA::WstringDef::_narrow(type);
- sprintf(&buf[0], "%sCORBA.string_%lu",
+ sprintf(&buf[0], "%sCORBA.string_%u",
prefix?"tns:":"",
s->bound());
return &buf[0];
@@ -956,7 +956,7 @@ CodeGenWSDL::Identifier
CodeGenWSDL::getTypename(CORBA::IDLType_ptr type, bool p
{
CORBA::SequenceDef_ptr s =
CORBA::SequenceDef::_narrow(type);
- sprintf(&buf[0], "%sCORBA.sequence_%lu_",
+ sprintf(&buf[0], "%sCORBA.sequence_%u_",
prefix?"tns:":"",
s->bound());
return &buf[0] + getTypename(s->element_type_def(),
false);
@@ -967,7 +967,7 @@ CodeGenWSDL::Identifier
CodeGenWSDL::getTypename(CORBA::IDLType_ptr type, bool p
{
CORBA::ArrayDef_ptr a =
CORBA::ArrayDef::_narrow(type);
- sprintf(&buf[0], "%sCORBA.array_%lu_",
+ sprintf(&buf[0], "%sCORBA.array_%u_",
prefix?"tns:":"",
a->length());
return &buf[0] + getTypename(a->element_type_def(),
false);
diff --git a/orb/uni_fromuni.cc b/orb/uni_fromuni.cc
index adfcbac..179ad37 100644
--- a/orb/uni_fromuni.cc
+++ b/orb/uni_fromuni.cc
@@ -1079,7 +1079,7 @@ cont: dest[di++] = ';';
}
else
{
- sprintf(buffer, "&#%lu;", character);
+ sprintf(buffer, "&#%u;", character);
strcpy(&dest[di], buffer);
assert(strlen(buffer) < UINT_MAX);
di += (uni_uword)strlen(buffer);
diff --git a/orb/uni_touni.cc b/orb/uni_touni.cc
index 829555e..b69f621 100644
--- a/orb/uni_touni.cc
+++ b/orb/uni_touni.cc
@@ -839,7 +839,7 @@ static uni_ulong ScanHTML(register const char *src,
uni_uword *length)
if(src[i] != ';') return(0l); /* no terminating ';'-sign */
buffer[mid]='\0';
- sscanf(buffer,"%lu", &upper);
+ sscanf(buffer,"%u", &upper);
*length = i+1;
return(upper);
}
--
2.19.2
1.1 src/patchsets/mico/9999/024_all_gcc8-warnings.patch
file :
http://sources.gentoo.org/viewvc.cgi/gentoo/src/patchsets/mico/9999/024_all_gcc8-warnings.patch?rev=1.1&view=markup
plain:
http://sources.gentoo.org/viewvc.cgi/gentoo/src/patchsets/mico/9999/024_all_gcc8-warnings.patch?rev=1.1&content-type=text/plain
Index: 024_all_gcc8-warnings.patch
===================================================================
>From 46fdd7c91bf78353004f8dbc7c8f15e1cd887af1 Mon Sep 17 00:00:00 2001
From: Michael Haubenwallner <[email protected]>
Date: Wed, 22 May 2019 15:30:37 +0200
Subject: [PATCH 19/19] fix some gcc-8 compiler warnings
cexp.y:532:20: warning: logical not is only applied to the left hand side of
comparison [-Wlogical-not-parentheses]
if (!pedantic < spec_long)
^
cexp.y:532:10: note: add parentheses around left hand side expression to
silence this warning
if (!pedantic < spec_long)
^~~~~~~~~
( )
cexp.y: In function 'yylex':
cexp.y:687:16: warning: type defaults to 'int' in declaration of 'num_chars'
[-Wimplicit-int]
register num_chars = 0;
---
cpp/cexp.y | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/cpp/cexp.y b/cpp/cexp.y
index 133539f..6d83155 100644
--- a/cpp/cexp.y
+++ b/cpp/cexp.y
@@ -529,7 +529,7 @@ parse_number (olen)
while (1) {
if (c == 'l' || c == 'L')
{
- if (!pedantic < spec_long)
+ if ((!pedantic) < spec_long))
yyerror ("too many `l's in integer constant");
spec_long++;
}
@@ -684,7 +684,7 @@ yylex ()
It is mostly copied from c-lex.c. */
{
register HOST_WIDE_INT result = 0;
- register num_chars = 0;
+ register int num_chars = 0;
unsigned width = MAX_CHAR_TYPE_SIZE;
int max_chars;
char *token_buffer;
--
2.19.2