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

Reply via email to