Hi Zoran, I realized that the "numberOfItems" related argument is invalid after discussing with the ticket raiser, I misunderstood the word "crashed". So, I will remove that part of the text from the commit message. Thanks to you also for clarifying.
Apart from that, the point of contention is about the assert behavior. You have a point that services have to be strict when handling bad SaNameT values. But that principle can be applied only to the extent of returning an API error code and we don't have to assert the user application. Furthermore, what the user passes is irrelevant in this CLM API's context because in this case it is an out-param. i.e. CLM will fill values in that structure before the call returns. What user specifies for an out-param is of no relevance and that's why this patch. Thanks, Mathi. > -----Original Message----- > From: Zoran Milinkovic [mailto:[email protected]] > Sent: Friday, September 09, 2016 4:38 PM > To: Mathivanan Naickan Palanivelu > Cc: [email protected] > Subject: RE: [PATCH 1 of 1] clm: avoid checking length of sanamet when clm > service is filling data [#2002] > > Hi Mathi, > > User cannot have bigger numberOfItem than the structure is allocated. > That's a user's fault and it must be detected in some way. > > If wrong input data is not detected at this place, it must be detected in > another place. > > All at all, I don't see anything wrong with the code. I don't see that the > test > case is a valid test case. > > With the support for long DN, CLM has become more strict for bad SaNameT > values, and assert bad SaNameT values. > > If you want to avoid assert, then the code can be rewritten to handle non- > extended SaNameT values longer than 255 characters. > > BR, > Zoran > > > -----Original Message----- > From: [email protected] [mailto:[email protected]] > Sent: den 9 september 2016 11:40 > To: Zoran Milinkovic > Cc: [email protected] > Subject: [PATCH 1 of 1] clm: avoid checking length of sanamet when clm > service is filling data [#2002] > > osaf/libs/agents/saf/clma/clma_api.c | 23 ----------------------- > 1 files changed, 0 insertions(+), 23 deletions(-) > > > When CLM is going to fill the values of notification buffer, there is no need > to > check the length values that is passed by the user. > Also, there can be cases when user has a bigger numofItems, but has > allocated lesser than that. > In such cases, dereferencing the notification can be avoided inside this > function. > > diff --git a/osaf/libs/agents/saf/clma/clma_api.c > b/osaf/libs/agents/saf/clma/clma_api.c > --- a/osaf/libs/agents/saf/clma/clma_api.c > +++ b/osaf/libs/agents/saf/clma/clma_api.c > @@ -117,17 +117,8 @@ static SaAisErrorT clma_validate_flags_b > > /* validate the notify buffer */ > if ((flags & SA_TRACK_CURRENT) && buf && buf->notification) { > - uint32_t i; > - > if (!buf->numberOfItems) > return SA_AIS_ERR_INVALID_PARAM; > - > - // Check that nodeName is not longer than 255 > - for(i=0; i<buf->numberOfItems; i++) { > - if(osaf_extended_name_length(&buf- > >notification[i].clusterNode.nodeName) >= SA_MAX_NAME_LENGTH) { > - return SA_AIS_ERR_INVALID_PARAM; > - } > - } > } > > /* Validate if flag is TRACK_CURRENT and no callback and no buffer > provided */ @@ -167,24 +158,10 @@ static SaAisErrorT > clma_validate_flags_b > > /* validate the notify buffer */ > if ((flags & SA_TRACK_CURRENT) && buf && buf->notification) { > - uint32_t i; > - > if (!buf->numberOfItems) { > TRACE_LEAVE(); > return SA_AIS_ERR_INVALID_PARAM; > } > - > - // Check that nodeName and EE are not longer than 255 > - for(i=0; i<buf->numberOfItems; i++) { > - if(osaf_extended_name_length(&buf- > >notification[i].clusterNode.nodeName) >= SA_MAX_NAME_LENGTH) { > - TRACE_LEAVE(); > - return SA_AIS_ERR_INVALID_PARAM; > - } > - if(osaf_extended_name_length(&buf- > >notification[i].clusterNode.executionEnvironment) >= > SA_MAX_NAME_LENGTH) { > - TRACE_LEAVE(); > - return SA_AIS_ERR_INVALID_PARAM; > - } > - } > } > > /* Validate if flag is TRACK_CURRENT and no callback and no buffer > provided */ ------------------------------------------------------------------------------ _______________________________________________ Opensaf-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/opensaf-devel
