diff options
author | Noriko Hosoi <nhosoi@redhat.com> | 2010-08-23 16:38:53 -0700 |
---|---|---|
committer | Noriko Hosoi <nhosoi@redhat.com> | 2010-08-23 16:38:53 -0700 |
commit | a3c4404cf6e1873a47d9e7c86b113bb6b91708b1 (patch) | |
tree | cb539edb7573e05837ceaf710a15ee6597806365 /lib/libaccess | |
parent | 48d11ee1c350bde4299619a5a54c62987f575ef1 (diff) | |
download | ds-a3c4404cf6e1873a47d9e7c86b113bb6b91708b1.tar.gz ds-a3c4404cf6e1873a47d9e7c86b113bb6b91708b1.tar.xz ds-a3c4404cf6e1873a47d9e7c86b113bb6b91708b1.zip |
Bug 611790 - fix coverify Defect Type: Null pointer dereferences issues 11940 - 12166
https://bugzilla.redhat.com/show_bug.cgi?id=611790
Resolves: bug 611790
Bug description: Fix coverify Defect Type: Null pointer dereferences issues 11940 - 12166
Fix description: Use the right pointer in LASIpAddPattern().
coverity ID: 11945
Diffstat (limited to 'lib/libaccess')
-rw-r--r-- | lib/libaccess/lasip.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/libaccess/lasip.cpp b/lib/libaccess/lasip.cpp index 0f3964d4..c59f5bbb 100644 --- a/lib/libaccess/lasip.cpp +++ b/lib/libaccess/lasip.cpp @@ -268,6 +268,10 @@ LASIpBuild(NSErr_t *errp, char *attr_name, CmpOp_t comparator, char *attr_patter char *plusptr; int retcode; + if (NULL == treetop) { + return ACL_RES_ERROR; + } + /* ip address can be delimited by space, tab, comma, or carriage return * only. */ @@ -343,8 +347,12 @@ LASIpAddPattern(NSErr_t *errp, int netmask, int pattern, LASIpTree_t **treetop) LASIpTree_t *curptr = NULL; /* pointer to the current node */ LASIpTree_t *newptr; + if (NULL == treetop) { + return ACL_RES_ERROR; + } + /* stop at the first 1 in the netmask from low to high */ - for (stopbit=0; stopbit<32; stopbit++) { + for (stopbit=0; stopbit<32; stopbit++) { if ((netmask&(1<<stopbit)) != 0) break; } @@ -353,7 +361,7 @@ LASIpAddPattern(NSErr_t *errp, int netmask, int pattern, LASIpTree_t **treetop) if (*treetop == (LASIpTree_t *)NULL) { /* No tree at all */ curptr = LASIpTreeAllocNode(errp); if (curptr == NULL) { - nserrGenerate(errp, ACLERRFAIL, ACLERR5100, ACL_Program, 1, XP_GetAdminStr(DBT_ipLasUnableToAllocateTreeNodeN_)); + nserrGenerate(errp, ACLERRFAIL, ACLERR5100, ACL_Program, 1, XP_GetAdminStr(DBT_ipLasUnableToAllocateTreeNodeN_)); return ACL_RES_ERROR; } *treetop = curptr; @@ -362,8 +370,8 @@ LASIpAddPattern(NSErr_t *errp, int netmask, int pattern, LASIpTree_t **treetop) /* Special case if the netmask is 0. */ if (stopbit > 31) { - curptr->action[0] = (LASIpTree_t *)LAS_EVAL_TRUE; - curptr->action[1] = (LASIpTree_t *)LAS_EVAL_TRUE; + (*treetop)->action[0] = (LASIpTree_t *)LAS_EVAL_TRUE; + (*treetop)->action[1] = (LASIpTree_t *)LAS_EVAL_TRUE; return 0; } |