summaryrefslogtreecommitdiffstats
path: root/ldap/synctools/passwordsync/passsync/syncserv.cpp
diff options
context:
space:
mode:
authorNathan Kinder <nkinder@redhat.com>2006-03-18 00:32:11 +0000
committerNathan Kinder <nkinder@redhat.com>2006-03-18 00:32:11 +0000
commit96e28e859035c4cf89915e889090791fd2d5ab8c (patch)
tree4b520b66b75ab19ede954a7e7be6adae7a26a3ae /ldap/synctools/passwordsync/passsync/syncserv.cpp
parentdbbe3de5b21b7b79283f699083f89b0c79571ea0 (diff)
186765 - Fixed memory leaks in passsync service
Diffstat (limited to 'ldap/synctools/passwordsync/passsync/syncserv.cpp')
-rw-r--r--ldap/synctools/passwordsync/passsync/syncserv.cpp27
1 files changed, 25 insertions, 2 deletions
diff --git a/ldap/synctools/passwordsync/passsync/syncserv.cpp b/ldap/synctools/passwordsync/passsync/syncserv.cpp
index bac518e8..86de672e 100644
--- a/ldap/synctools/passwordsync/passsync/syncserv.cpp
+++ b/ldap/synctools/passwordsync/passsync/syncserv.cpp
@@ -242,6 +242,7 @@ void PassSyncService::Run()
}
exit:
+ clearSet(&passInfoList);
CloseHandle(passhookEventHandle);
}
@@ -254,7 +255,7 @@ int PassSyncService::SyncPasswords()
PASS_INFO_LIST emptyPassInfoList;
PASS_INFO_LIST_ITERATOR currentPassInfo;
PASS_INFO_LIST_ITERATOR tempPassInfo;
- char* dn;
+ char* dn = NULL;
int tempSize = passInfoList.size();
if(loadSet(&passInfoList, dataFilename) == 0)
@@ -349,6 +350,9 @@ int PassSyncService::SyncPasswords()
timeStamp(&outLog);
outLog << "Deferring password change for " << currentPassInfo->username << endl;
currentPassInfo++;
+ // free dn
+ ldap_memfree(dn);
+ dn = NULL;
continue;
}
else
@@ -366,6 +370,16 @@ int PassSyncService::SyncPasswords()
timeStamp(&outLog);
outLog << "Removing password change from list" << endl;
}
+
+ // free the dn
+ ldap_memfree(dn);
+ dn = NULL;
+
+ // free the username and password
+ free(tempPassInfo->username);
+ free(tempPassInfo->password);
+
+ // remove the completed change from the list
passInfoList.erase(tempPassInfo);
}
}
@@ -447,7 +461,10 @@ int PassSyncService::QueryUsername(char* username)
int result = 0;
char searchFilter[SYNCSERV_BUF_SIZE];
- results = NULL;
+ if (results != NULL) {
+ ldap_msgfree(results);
+ results = NULL;
+ }
_snprintf(searchFilter, SYNCSERV_BUF_SIZE, "(%s=%s)", ldapUsernameField, username);
@@ -640,6 +657,12 @@ void PassSyncService::UpdateBackoff()
tempPassInfo = currentPassInfo;
currentPassInfo++;
+
+ // free the username and password
+ free(tempPassInfo->username);
+ free(tempPassInfo->password);
+
+ // remove the change from the list
passInfoList.erase(tempPassInfo);
}
else