ldap/servers/slapd/dn.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
New commits:
commit 54a3d99a96d84b42f680da43c7f638009c0f64d4
Author: Noriko Hosoi <nhosoi(a)jiji.usersys.redhat.com>
Date: Tue Nov 1 16:05:12 2011 -0700
Bug 750624 - Fix Coverity (11053) Explicit null dereferenced:
slapi_dn_normalize_ext (slapd/dn.c)
https://bugzilla.redhat.com/show_bug.cgi?id=750624
Bug Description: Dereferencing null variable "d".
There is no possibility that (rc > 0) && (d == NULL), but it's
safe to check if d is not NULL before assigning '\0' to *d.
Fix Description: add checking if "d" is NULL or not before
assigning '\0' to *d.
diff --git a/ldap/servers/slapd/dn.c b/ldap/servers/slapd/dn.c
index e5b9db9..2b0b338 100644
--- a/ldap/servers/slapd/dn.c
+++ b/ldap/servers/slapd/dn.c
@@ -515,7 +515,7 @@ slapi_dn_normalize_ext(char *src, size_t src_len, char **dest, size_t
*dest_len)
int chkblank = 0;
int is_dn_syntax = 0;
- if (NULL == dest) {
+ if ((NULL == dest) || (NULL == dest_len)) {
goto bail;
}
if (NULL == src) {
@@ -544,7 +544,7 @@ slapi_dn_normalize_ext(char *src, size_t src_len, char **dest, size_t
*dest_len)
}
}
if (0 == src_len) { /* src == "" */
- goto bail;
+ goto bail; /* need to bail after setting up *dest and rc */
}
ends = src + src_len;
@@ -1081,7 +1081,7 @@ bail:
}
}
*dest_len = 0;
- } else if (rc > 0) {
+ } else if (d && rc > 0) {
/* We terminate the str with NULL only when we allocate the str */
*d = '\0';
}