ABR Analyze Buffer overflow - Klockwork issue

773 Views Asked by At
#include<stdio.h>
#include<string.h>

#define RPTE_TE_TNL (x)  x->pTeTnlInfo
#define RSVPTE_TNL_NAME(x)  x->au1TnlName
#define LENGTH 32
#define STRLEN(s) strlen((const char *)(s))

typedef char INT1;

unsigned short length;

struct _tTeTnlInfo
{
    unsigned char       au1TnlName[LENGTH];
}

length = unsigned short( STRLEN ((INT1 *)RSVPTE_TNL_NAME (RPTE_TE_TNL (pRsvpTeTnlInfo))) );

Klockwork gives an error for above line - ABR Analyze Buffer overflow, array index of 'pRsvpTeTnlInfo->pTeTnlInfo->au1TnlName' may be out of bounds. Array 'pRsvpTeTnlInfo->pTeTnlInfo->au1TnlName' of size 32 may use index value(s) 0..INT_MAX-1.

I am not able to find out the root cause, why klocwork gives this error. Can someone help me out ?

0

There are 0 best solutions below