Skip to content

Commit

Permalink
zebra: Fix NULL pointer dereference
Browse files Browse the repository at this point in the history
The `locator` pointer is dereferenced before ensuring it is not NULL.
Fix the issue by checking that the pointer is not NULL before
dereferencing it.

Fixes 1594013

** CID 1594013:  Null pointer dereferences  (REVERSE_INULL)
/zebra/zebra_srv6.c: 961 in zebra_srv6_sid_compose()

________________________________________________________________________________________________________
*** CID 1594013:  Null pointer dereferences  (REVERSE_INULL)
/zebra/zebra_srv6.c: 961 in zebra_srv6_sid_compose()
955     				   struct srv6_locator *locator,
956     				   uint32_t sid_func)
957     {
958     	uint8_t offset, func_len;
959     	struct srv6_sid_format *format = locator->sid_format;
960
     CID 1594013:  Null pointer dereferences  (REVERSE_INULL)
     Null-checking "locator" suggests that it may be null, but it has already been dereferenced on all paths leading to the check.
961     	if (!sid_value || !locator)
962     		return false;
963
964     	if (format) {
965     		offset = format->block_len + format->node_len;
966     		func_len = format->function_len;

Signed-off-by: Carmine Scarpitta <[email protected]>
  • Loading branch information
cscarpitta committed Jun 24, 2024
1 parent 375a02d commit df97a9d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion zebra/zebra_srv6.c
Original file line number Diff line number Diff line change
Expand Up @@ -956,11 +956,12 @@ static bool zebra_srv6_sid_compose(struct in6_addr *sid_value,
uint32_t sid_func)
{
uint8_t offset, func_len;
struct srv6_sid_format *format = locator->sid_format;
struct srv6_sid_format *format;

if (!sid_value || !locator)
return false;

format = locator->sid_format;
if (format) {
offset = format->block_len + format->node_len;
func_len = format->function_len;
Expand Down

0 comments on commit df97a9d

Please sign in to comment.