瀏覽代碼

Bug 690584 - #10641 reslimit_bv2int - fix coverity resource leak issues

https://bugzilla.redhat.com/show_bug.cgi?id=690584
Resolves: bug 690584
Bug Description: #10641 reslimit_bv2int - fix coverity resource leak issues
Reviewed by: nhosoi (Thanks!)
Branch: master
Fix Description: The comment was incorrect - slapi_value_get_int does handle
signed values correctly - it uses the same function atoi - the fix is to
get rid of reslimit_bv2int
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: no
Rich Megginson 14 年之前
父節點
當前提交
6c9822577b
共有 1 個文件被更改,包括 3 次插入37 次删除
  1. 3 37
      ldap/servers/slapd/resourcelimit.c

+ 3 - 37
ldap/servers/slapd/resourcelimit.c

@@ -181,7 +181,6 @@ static void reslimit_connext_destructor( void *extension, void *object,
 		void *parent );
 static int reslimit_get_ext( Slapi_Connection *conn, const char *logname,
 		SLAPIResLimitConnData **rlcdpp );
-static int reslimit_bv2int( const struct berval *bvp );
 static char ** reslimit_get_registered_attributes();
 
 
@@ -327,38 +326,6 @@ reslimit_get_ext( Slapi_Connection *conn, const char *logname,
 }
 
 
-/*
- * utility function to convert a string-represented integer to an int.
- *
- * XXXmcs: wouldn't need this if slapi_value_get_int() returned a signed int!
- */
-static int
-reslimit_bv2int( const struct berval *bvp )
-{
-	int		rc = 0;
-	char	smallbuf[ 25 ], *buf;
-
-	if ( bvp != NULL ) {
-		/* make a copy to ensure it is zero-terminated */
-		if ( bvp->bv_len < sizeof( smallbuf )) {
-			buf = smallbuf;
-		} else {
-			buf = slapi_ch_malloc( bvp->bv_len + 1 );
-		}
-		memcpy( buf, bvp->bv_val, bvp->bv_len);
-		buf[ bvp->bv_len ] = '\0';
-
-		rc = atoi( buf );
-
-		if ( buf != smallbuf ) {
-			slapi_ch_free( (void **)&smallbuf );
-		}
-	}
-
-	return( rc );
-}
-
-
 /**** Semi-public functions start here ***********************************/
 /*
  * These functions are exposed to other parts of the server only, i.e.,
@@ -464,11 +431,10 @@ reslimit_update_from_entry( Slapi_Connection *conn, Slapi_Entry *e )
 				&actual_type_name, 0, &free_flags )) {
 			Slapi_Value			*v;
 			int					index;
-			const struct berval	*bvp;
 
-			if (( index = slapi_valueset_first_value( vs, &v )) != -1 &&
-					( bvp = slapi_value_get_berval( v )) != NULL ) {
-				rlcdp->rlcd_integer_value[ i ] = reslimit_bv2int( bvp );
+			if ((( index = slapi_valueset_first_value( vs, &v )) != -1) &&
+				( v != NULL )) {
+				rlcdp->rlcd_integer_value[ i ] = slapi_value_get_int( v );
 				rlcdp->rlcd_integer_available[ i ] = PR_TRUE;
 
 				LDAPDebug( SLAPI_RESLIMIT_TRACELEVEL,