[Fedora-directory-commits] winsync/passwordsync/passhook passhook.cpp, 1.9, 1.10

Nathan Kinder nkinder at fedoraproject.org
Wed Mar 25 18:00:03 UTC 2009


Author: nkinder

Update of /cvs/dirsec/winsync/passwordsync/passhook
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv26335/passhook

Modified Files:
	passhook.cpp 
Log Message:
Related: 490048
Summary: Handle NULL Username and Password parameters in PasswordChangeNotify callback.



Index: passhook.cpp
===================================================================
RCS file: /cvs/dirsec/winsync/passwordsync/passhook/passhook.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- passhook.cpp	30 Mar 2006 22:59:25 -0000	1.9
+++ passhook.cpp	25 Mar 2009 18:00:00 -0000	1.10
@@ -59,11 +59,20 @@
 	fstream outLog;
 	DWORD waitRes;
 
+	// If UserName is NULL, just return STATUS_SUCCESS
+	if (UserName == NULL) {
+		goto exit;
+	}
+
 	// This memory will be freed in SavePasshookChange
 	if ( newPassInfo = (PASS_INFO *) malloc(sizeof(PASS_INFO)) ) {
 		// These get freed in SavePasshookChange by calling clearSet
 		newPassInfo->username = (char*)malloc((UserName->Length / 2) + 1);
-		newPassInfo->password = (char*)malloc((Password->Length / 2) + 1);
+		if (Password != NULL) {
+			newPassInfo->password = (char*)malloc((Password->Length / 2) + 1);
+		} else {
+			newPassInfo->password = (char*)malloc(1);
+		}
 	} else {
 		goto exit;
 	}
@@ -71,9 +80,13 @@
 	// Fill in the password change struct
 	if (newPassInfo->username && newPassInfo->password) {
                 _snprintf(newPassInfo->username, (UserName->Length / 2), "%S", UserName->Buffer);
-                _snprintf(newPassInfo->password, (Password->Length / 2), "%S", Password->Buffer);
-                newPassInfo->username[UserName->Length / 2] = '\0';
-                newPassInfo->password[Password->Length / 2] = '\0';
+		newPassInfo->username[UserName->Length / 2] = '\0';
+		if (Password != NULL) {
+                	_snprintf(newPassInfo->password, (Password->Length / 2), "%S", Password->Buffer);
+			newPassInfo->password[Password->Length / 2] = '\0';
+		} else {
+			newPassInfo->password[0] = '\0';
+		}
 
 		// Backoff
                 newPassInfo->backoffCount = 0;




More information about the Fedora-directory-commits mailing list