-
Bug
-
Resolution: Unresolved
-
Critical
-
jdk 1.7
jenkins 1.609.1
os ubuntu12.04.4
We doubt whehter there is a memory leak in the method of callback in Class PAM of libpam4j-1.9.jar.
It calls libc.calloc(pam_response.SIZE,num_msg); but the function of free is not called.
//PAMSecurityRealm.java
@Override
protected synchronized UserDetails authenticate(String username, String password) throws AuthenticationException {
try
catch (PAMException e)
{ throw new BadCredentialsException(e.getMessage(),e); }}
######################################
//class PAM
public PAM(String serviceName) throws PAMException {
pam_conv conv = new pam_conv(new PamCallback() {
public int callback(int num_msg, Pointer msg, Pointer resp, Pointer _) {
LOGGER.fine("pam_conv num_msg="+num_msg);
if(password==null)
return PAM_CONV_ERR;
// allocates pam_response[num_msg]. the caller will free this
Pointer m = libc.calloc(pam_response.SIZE,num_msg);
resp.setPointer(0,m);
for( int i=0; i<num_msg; i++ ) {
pam_message pm = new pam_message(msg.getPointer(POINTER_SIZE*i));
LOGGER.fine(pm.msg_style+":"+pm.msg);
if(pm.msg_style==PAM_PROMPT_ECHO_OFF)
}
return PAM_SUCCESS;
}
});
PointerByReference phtr = new PointerByReference();
check(libpam.pam_start(serviceName,null,conv,phtr), "pam_start failed");
pht = new pam_handle_t(phtr.getValue());
}
public UnixUser authenticate(String username, String password) throws PAMException {
this.password = password;
try
finally
{ this.password = null; }}