Skip to content

Commit

Permalink
add ziti_address compare null checks
Browse files Browse the repository at this point in the history
  • Loading branch information
ekoby committed Jun 21, 2022
1 parent 559909c commit 6efa4d6
Showing 1 changed file with 22 additions and 15 deletions.
37 changes: 22 additions & 15 deletions library/internal_model.c
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
/*
Copyright (c) 2020 NetFoundry, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Copyright (c) 2020-2022. NetFoundry Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.


#include <internal_model.h>
Expand All @@ -24,12 +22,19 @@ limitations under the License.
typedef uint32_t in_addr_t;
#define strcasecmp stricmp
#else

#include <arpa/inet.h>

#endif

#include <string.h>
#include "ziti/ziti_buffer.h"

#define null_checks(lh, rh) \
if ((lh) == (rh)) { return 0; } \
if ((lh) == NULL) { return -1; } \
if ((rh) == NULL) { return 1; }

IMPL_MODEL(ziti_posture_query, ZITI_POSTURE_QUERY_MODEL)

IMPL_MODEL(ziti_posture_query_set, ZITI_POSTURE_QUERY_SET_MODEL)
Expand Down Expand Up @@ -142,6 +147,8 @@ int ziti_service_get_config(ziti_service *service, const char *cfg_type, void *c
}

static int cmp_ziti_address0(ziti_address *lh, ziti_address *rh) {
null_checks(lh, rh)

if (lh->type != rh->type) {
return (int) lh->type - (int) rh->type;
}
Expand Down

0 comments on commit 6efa4d6

Please sign in to comment.