---

** [tickets:#2548] amfa: process crashed when invoking saAmfComponentRegister() 
with SA_AMF_COMPONENT_NAME not set**

**Status:** assigned
**Milestone:** 5.17.10
**Created:** Wed Aug 09, 2017 10:50 AM UTC by Nguyen TK Luu
**Last Updated:** Wed Aug 09, 2017 10:50 AM UTC
**Owner:** Nguyen TK Luu


The issue was found when testing the API saAmfComponentRegister(). Start a 
process that calls saAmfInitialize(), then calls saAmfComponentRegister() with 
a non-existing component name, with the environment variable 
SA_AMF_COMPONENT_NAME deliberately not set (not started by AMF), the process 
will get aborted (osaf_abort(1)).

That was caused by the following buggy condition check in the 
saAmfComponentRegister() function:

~~~
  ...
  /* retrieve AvA CB */
  if (!(cb = (AVA_CB *)ncshm_take_hdl(NCS_SERVICE_ID_AVA, gl_ava_hdl)) ||
      !m_AVA_FLAG_IS_COMP_NAME(cb)) {
    TRACE_4("SA_AIS_ERR_LIBRARY: Unable to retrieve cb handle");
    rc = SA_AIS_ERR_LIBRARY;
    goto done;
  }
  /* acquire cb read lock */
  m_NCS_LOCK(&cb->lock, NCS_LOCK_READ);
  ...
  
  done:
  /* release cb read lock and return handles */
  if (cb) {
    m_NCS_UNLOCK(&cb->lock, NCS_LOCK_READ);
    ncshm_give_hdl(gl_ava_hdl);
  }
  ...

  TRACE_LEAVE2("rc:%u", rc);
  return rc;
~~~

In this case, the !m_AVA_FLAG_IS_COMP_NAME(cb) check failed as 
SA_AMF_COMPONENT_NAME was not set, the execution jumped to 'done:' which tried 
to unlock a not-owned mutex (not previously locked yet), leading to 
osaf_abort() of the invoking process.


---

Sent from sourceforge.net because opensaf-tickets@lists.sourceforge.net is 
subscribed to https://sourceforge.net/p/opensaf/tickets/

To unsubscribe from further messages, a project admin can change settings at 
https://sourceforge.net/p/opensaf/admin/tickets/options.  Or, if this is a 
mailing list, you can unsubscribe from the mailing list.
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Opensaf-tickets mailing list
Opensaf-tickets@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensaf-tickets

Reply via email to