diff options
author | Johnny Willemsen <jwillemsen@remedy.nl> | 2013-05-30 18:51:35 +0000 |
---|---|---|
committer | Johnny Willemsen <jwillemsen@remedy.nl> | 2013-05-30 18:51:35 +0000 |
commit | 058ee5700ef4a7ae5ab7e6b2e1eed2b90396c142 (patch) | |
tree | dd50528ca2448edebd70d06d94fec96b145feccd /ACE | |
parent | 0f1a5632d6c3160ada3e7b5eab92bccc062e3d10 (diff) | |
download | ATCD-058ee5700ef4a7ae5ab7e6b2e1eed2b90396c142.tar.gz |
Thu May 30 18:50:44 UTC 2013 Johnny Willemsen <jwillemsen@remedy.nl>
* ace/Malloc_Allocator.h:
* ace/Shared_Memory_Pool.h:
Doxygen changes
* ace/Shared_Memory_Pool.cpp:
Fixed Coverity 300041 Dereference after null check
Diffstat (limited to 'ACE')
-rw-r--r-- | ACE/ChangeLog | 9 | ||||
-rw-r--r-- | ACE/ace/Malloc_Allocator.h | 10 | ||||
-rw-r--r-- | ACE/ace/Shared_Memory_Pool.cpp | 43 | ||||
-rw-r--r-- | ACE/ace/Shared_Memory_Pool.h | 4 |
4 files changed, 38 insertions, 28 deletions
diff --git a/ACE/ChangeLog b/ACE/ChangeLog index 9cfcc40e2de..57bf78c446a 100644 --- a/ACE/ChangeLog +++ b/ACE/ChangeLog @@ -1,3 +1,12 @@ +Thu May 30 18:50:44 UTC 2013 Johnny Willemsen <jwillemsen@remedy.nl> + + * ace/Malloc_Allocator.h: + * ace/Shared_Memory_Pool.h: + Doxygen changes + + * ace/Shared_Memory_Pool.cpp: + Fixed Coverity 300041 Dereference after null check + Wed May 29 03:35:59 UTC 2013 Douglas C. Schmidt <schmidt@dre.vanderbilt.edu> * ace/Connector.h: Used reinterpret_cast<const diff --git a/ACE/ace/Malloc_Allocator.h b/ACE/ace/Malloc_Allocator.h index 1ac2f9d55ee..f721d80c60f 100644 --- a/ACE/ace/Malloc_Allocator.h +++ b/ACE/ace/Malloc_Allocator.h @@ -44,8 +44,8 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL * * This class uses the new/delete operators to allocate and free up * memory. Please note that the only methods that are supported are - * <malloc>, <calloc>, and <free>. All other methods are no-ops that - * return -1 and set @c errno to <ENOTSUP>. If you require this + * malloc(), calloc(), and free(). All other methods are no-ops that + * return -1 and set @c errno to @c ENOTSUP. If you require this * functionality, please use: ACE_Allocator_Adapter <ACE_Malloc * <ACE_LOCAL_MEMORY_POOL, MUTEX> >, which will allow you to use the * added functionality of bind/find/etc. while using the new/delete @@ -88,11 +88,11 @@ private: * @brief Defines a class that provided a highly optimized memory * management scheme for allocating memory statically. * - * This class manages a fixed-size <POOL_SIZE> of memory. Every - * time <malloc>/<calloc> is called, it simply moves an internal + * This class manages a fixed-size @c POOL_SIZE of memory. Every + * time malloc()/calloc() is called, it simply moves an internal * index forward and returns a pointer to the requested chunk. * All memory is allocated statically (typically via the - * ACE_Static_Allocator template) and <free> is a no-op. This + * ACE_Static_Allocator template) and free() is a no-op. This * behavior is useful for use-cases where all the memory * allocation needs are known in advance and no deletions ever * occur. diff --git a/ACE/ace/Shared_Memory_Pool.cpp b/ACE/ace/Shared_Memory_Pool.cpp index cb55c6dd202..4c6a4e10af8 100644 --- a/ACE/ace/Shared_Memory_Pool.cpp +++ b/ACE/ace/Shared_Memory_Pool.cpp @@ -144,37 +144,39 @@ ACE_Shared_Memory_Pool::commit_backing_store_name (size_t rounded_bytes, return 0; } -// Handle SIGSEGV and SIGBUS signals to remap shared memory properly. - +/// Handle SIGSEGV and SIGBUS signals to remap shared memory properly. int -ACE_Shared_Memory_Pool::handle_signal (int , siginfo_t *siginfo, ucontext_t *) +ACE_Shared_Memory_Pool::handle_signal (int, siginfo_t *siginfo, ucontext_t *) { ACE_TRACE ("ACE_Shared_Memory_Pool::handle_signal"); - // ACELIB_DEBUG ((LM_DEBUG, ACE_TEXT ("signal %S occurred\n"), signum)); // While FreeBSD 5.X has a siginfo_t struct with a si_addr field, // it does not define SEGV_MAPERR. #if defined (ACE_HAS_SIGINFO_T) && !defined (ACE_LACKS_SI_ADDR) && \ (defined (SEGV_MAPERR) || defined (SEGV_MEMERR)) + if (siginfo == 0) + return -1; + ACE_OFF_T offset; + // Make sure that the pointer causing the problem is within the // range of the backing store. - - if (siginfo != 0) + // ACELIB_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) si_signo = %d, si_code = %d, addr = %u\n"), siginfo->si_signo, siginfo->si_code, siginfo->si_addr)); + size_t counter = 0; + if (this->in_use (offset, counter) == -1) { - // ACELIB_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) si_signo = %d, si_code = %d, addr = %u\n"), siginfo->si_signo, siginfo->si_code, siginfo->si_addr)); - size_t counter; - if (this->in_use (offset, counter) == -1) - ACELIB_ERROR ((LM_ERROR, - ACE_TEXT ("(%P|%t) %p\n"), - ACE_TEXT ("in_use"))); - else if (!(siginfo->si_code == SEGV_MAPERR - && siginfo->si_addr < (((char *) this->base_addr_) + offset) - && siginfo->si_addr >= ((char *) this->base_addr_))) - ACELIB_ERROR_RETURN ((LM_ERROR, - "(%P|%t) address %u out of range\n", - siginfo->si_addr), - -1); + ACELIB_ERROR ((LM_ERROR, + ACE_TEXT ("(%P|%t) %p\n"), + ACE_TEXT ("in_use"))); + } + else if (!(siginfo->si_code == SEGV_MAPERR + && siginfo->si_addr < (((char *) this->base_addr_) + offset) + && siginfo->si_addr >= ((char *) this->base_addr_))) + { + ACELIB_ERROR_RETURN ((LM_ERROR, + "(%P|%t) address %u out of range\n", + siginfo->si_addr), + -1); } // The above if case will check to see that the address is in the @@ -182,8 +184,7 @@ ACE_Shared_Memory_Pool::handle_signal (int , siginfo_t *siginfo, ucontext_t *) // pointer wants to point into. Find the segment that someone else // has used and attach to it (flabar@vais.net) - size_t counter; // ret value to get shmid from the st table. - + counter = 0; // ret value to get shmid from the st table. if (this->find_seg (siginfo->si_addr, offset, counter) == -1) ACELIB_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("(%P|%t) %p\n"), diff --git a/ACE/ace/Shared_Memory_Pool.h b/ACE/ace/Shared_Memory_Pool.h index 27c113b1c0f..344d2ce92b0 100644 --- a/ACE/ace/Shared_Memory_Pool.h +++ b/ACE/ace/Shared_Memory_Pool.h @@ -142,7 +142,7 @@ protected: /** * Commits a new shared memory segment if necessary after an - * <acquire> or a signal. @a offset is set to the new offset into + * acquire() or a signal. @a offset is set to the new offset into * the backing store. */ virtual int commit_backing_store_name (size_t rounded_bytes, @@ -198,7 +198,7 @@ protected: /// Handle SIGSEGV and SIGBUS signals to remap shared memory /// properly. - virtual int handle_signal (int signum, siginfo_t *, ucontext_t *); + virtual int handle_signal (int, siginfo_t *siginfo, ucontext_t *); }; ACE_END_VERSIONED_NAMESPACE_DECL |