File novell-nortelplugins-ppc_support.patch of Package novell-nortelplugins

Index: novell-nortelplugins-0.1.3/nortel/ike/nortel_inf.h
===================================================================
--- novell-nortelplugins-0.1.3.orig/nortel/ike/nortel_inf.h
+++ novell-nortelplugins-0.1.3/nortel/ike/nortel_inf.h
@@ -26,9 +26,16 @@
 #define INTERNAL_IPV4_NETMASK		2		
 #define INTERNAL_IPV4_DNS			3
 
-#define NORTEL_XAUTH_TYPE 			0x0D00
-#define XAUTH_USER_NAME      		0x0E00
-#define XAUTH_USER_PASSWORD		0x0F00
+/* support big endian for ppc */
+#if BYTE_ORDER == BIG_ENDIAN
+#define NORTEL_XAUTH_TYPE           0x000D
+#define XAUTH_USER_NAME             0x000E
+#define XAUTH_USER_PASSWORD         0x000F
+#else
+#define NORTEL_XAUTH_TYPE           0x0D00
+#define XAUTH_USER_NAME             0x0E00
+#define XAUTH_USER_PASSWORD         0x0F00
+#endif
 
 //Nortel properitary stuff
 #define CFG_BIFURCATION     	       0x4000
Index: novell-nortelplugins-0.1.3/nortel/cli/profile.c
===================================================================
--- novell-nortelplugins-0.1.3.orig/nortel/cli/profile.c
+++ novell-nortelplugins-0.1.3/nortel/cli/profile.c
@@ -22,23 +22,21 @@
 #define MAX_STRING_LEN      128
 #define PASSWORD_STRING_LENGTH 256
 
-char last_succ_user [128];
+char last_succ_user [MAX_STRING_LEN];
 
 static int getPassword (char *password);
 
 int nortel_get_privdata(char *buf, void *gp);
 int nortel_create_vendor_profile(char *vendorProfileFileName);
-int nortel_get_privdata(char *buf, void *gp);
 
 /* Call back function to create a vendor profile */
 int nortel_create_vendor_profile(char *vendorProfileFileName)
 {
-	char groupN[MAX_STRING_LEN];
-	char groupP[MAX_STRING_LEN];
-	char gatewayIP[MAX_STRING_LEN];
-	int c;
+	char groupN[MAX_STRING_LEN] = {'\0'};
+	char groupP[MAX_STRING_LEN] = {'\0'};
+	char gatewayIP[MAX_STRING_LEN] = {'\0'};
 
-	char fileName[MAX_PATH_LEN];
+	char fileName[MAX_PATH_LEN] = {'\0'};
     
 	memset(groupN,'\0',MAX_STRING_LEN-1);
 	memset(groupP,'\0',MAX_STRING_LEN-1);
@@ -46,9 +44,14 @@ int nortel_create_vendor_profile(char *v
 	/* Get Group Name and Group Password */
 	printf("Group Name		: ");
 
-	// FIXME : buffer overflow
-	while ((c = getchar()) != '\n')
-	 	strcat(groupN,(char *)&c);
+	// don't use getchar() anymore, use fgets for avoiding
+	// buffer overflow
+	if (NULL != fgets(groupN, MAX_STRING_LEN - 1, stdin)) {
+		char *temp = NULL;
+		temp = strrchr(groupN, '\n');
+		if (temp != NULL)
+			*temp = '\0';
+	}
 
 	printf("Group Password		: ");
 	getPassword(groupP);
@@ -72,24 +75,24 @@ int nortel_create_vendor_profile(char *v
 int nortel_get_privdata(char *buf, void *gp)
 {
 	struct pluginInfo *pInfo = (struct pluginInfo *)gp;
-	char groupName[128] = {'\0'};
-	char groupPassword[128] = {'\0'}; 
-	char groupUnEncPassword[128] = {'\0'};
-	char userName[128] = {'\0'}; 
-	char userPassword[128] = {'\0'}; 
-	char newUserName[128] = {'\0'};
+	char groupName[MAX_STRING_LEN] = {'\0'};
+	char groupPassword[MAX_STRING_LEN] = {'\0'};
+	char groupUnEncPassword[MAX_STRING_LEN] = {'\0'};
+	char userName[MAX_STRING_LEN] = {'\0'};
+	char userPassword[MAX_STRING_LEN] = {'\0'};
+	char newUserName[MAX_STRING_LEN] = {'\0'};
 	int bufLen = 0;
 	char *currptr = buf;
 
 	if(pInfo->ifInfo.authentication_type != CERTIFICATE)
 	{
-		int c, gpEncFlag = 1;
+		int gpEncFlag = 1;
 	
-		memset(userName,'\0',127);
-		memset(newUserName,'\0',127);
-		memset(groupName,'\0',127);
-		memset(groupPassword, '\0',127);
-		memset(groupUnEncPassword, '\0',127);
+		memset(userName,'\0',MAX_STRING_LEN - 1);
+		memset(newUserName,'\0',MAX_STRING_LEN - 1);
+		memset(groupName,'\0',MAX_STRING_LEN - 1);
+		memset(groupPassword, '\0',MAX_STRING_LEN - 1);
+		memset(groupUnEncPassword, '\0',MAX_STRING_LEN - 1);
 
 		if (pInfo->ifInfo.withProfileFile)
 		{
@@ -107,10 +110,17 @@ int nortel_get_privdata(char *buf, void 
 			printf("User Name		: ");
 			printf("[%s]", userName);
 
-			while ((c = getchar()) != '\n')
-			{
-	 			strcat(newUserName,(char *)&c);
-				strcpy(userName, (const char *) newUserName);
+			// don't use getchar anymore, it's a problem when in PPC,
+			// use fgets can avoid buffer overflow.
+			if (NULL != fgets(newUserName, MAX_STRING_LEN - 1, stdin)) {
+				char *temp = NULL;
+				temp = strrchr(newUserName, '\n');
+				if (temp != NULL)
+					*temp = '\0';
+			}
+			// when user just input '\n' don't set userName
+			if (strlen(newUserName) > 0) {
+				strncpy(userName, newUserName, MAX_STRING_LEN - 1);
 			}
 
 			//printf("User name selected : %s, newuser : %s\n",userName, newUserName);
@@ -157,14 +167,17 @@ int nortel_get_privdata(char *buf, void 
 			if (!gpEncFlag)
 			{
 				strcpy(groupUnEncPassword, groupPassword);
-				memset(groupPassword, '\0',127);
-				nortel_enc_password(groupUnEncPassword, strlen(groupUnEncPassword), groupPassword, 128);
+				memset(groupPassword, '\0', MAX_STRING_LEN - 1);
+				nortel_enc_password(groupUnEncPassword,
+					   	strlen(groupUnEncPassword),
+						groupPassword,
+						MAX_STRING_LEN);
 			}	
 		}
 	}
 
 	//Update the username for storing in the profile
-	memset(last_succ_user,'\0',128);
+	memset(last_succ_user,'\0', MAX_STRING_LEN - 1);
 	strcpy(last_succ_user, (const char *) userName);
 	
 	*(int32_t *) currptr = (int) (pInfo->ifInfo.server_ip_addr);
Index: novell-nortelplugins-0.1.3/nortel/ike/attrgen.c
===================================================================
--- novell-nortelplugins-0.1.3.orig/nortel/ike/attrgen.c
+++ novell-nortelplugins-0.1.3/nortel/ike/attrgen.c
@@ -21,19 +21,32 @@ extern int nat_dst_float_port;
 
 static int setAttribute_l(struct isakmp_data *data, u_int16_t type, u_int32_t val)
 { 
+    plog(LLV_DEBUG2, LOCATION, NULL, "setAttribute_l type:\n");
+	plogdump(LLV_DEBUG2, &type, sizeof(u_int16_t));
+
     data->type = htons((u_int16_t)type) | 0x8000;
     data->lorv = htons((u_int16_t)val);
+
+    plog(LLV_DEBUG2, LOCATION, NULL, "setAttribute_l type after htons:\n");
+	plogdump(LLV_DEBUG2, &data->type, sizeof(u_int16_t));
+
     return sizeof(struct isakmp_data);
 }
 
 static int setAttribute_v(struct isakmp_data *data, u_int16_t type, caddr_t val, u_int16_t len )
 { 
+    plog(LLV_DEBUG2, LOCATION, NULL, "setAttribute_v type:\n");
+	plogdump(LLV_DEBUG2, &type, sizeof(u_int16_t));
+
     data->type = htons((u_int16_t)type);
+
+    plog(LLV_DEBUG2, LOCATION, NULL, "setAttribute_v type after htons:\n");
+	plogdump(LLV_DEBUG2, &data->type, sizeof(u_int16_t));
+
     data->lorv = (u_int16_t)len;
     if(val)
         memcpy(data+1,val,len);
     return (sizeof(struct isakmp_data) + len) ;
-
 }
 
 /*****************IKE ATTRIBUTES ******************/
@@ -67,6 +80,8 @@ int replyXauthType(struct isakmp_data *d
 
 int replyXauthUserName(struct isakmp_data *data, int unamelen, caddr_t uname)
 {
+    plog(LLV_DEBUG2, LOCATION, NULL, "replyXauthUserName:\n");
+    plogdump(LLV_DEBUG2, uname, unamelen);
     return setAttribute_v ( data, XAUTH_USER_NAME, uname, unamelen );
 }
 
Index: novell-nortelplugins-0.1.3/nortel/ike/callbacks.c
===================================================================
--- novell-nortelplugins-0.1.3.orig/nortel/ike/callbacks.c
+++ novell-nortelplugins-0.1.3/nortel/ike/callbacks.c
@@ -230,7 +230,9 @@ int opaqueIDCallback(void *gprivdata, vo
 int presharedKeyCallback(void *gprivdata, void *hprivdata, void *inArray, void **outArray)
 {
 	vchar_t *preshared_key = NULL;
-	plog(LLV_DEBUG,LOCATION,NULL,"groupname:%s", ((struct nortelHandle *)gprivdata)->cfg->grpname.v);
+	plog(LLV_DEBUG,LOCATION,NULL,"groupname:");
+	plogdump(LLV_DEBUG, ((struct nortelHandle *)gprivdata)->cfg->grpname.v,
+		((struct nortelHandle *)gprivdata)->cfg->grpname.l);
 	plog(LLV_DEBUG,LOCATION,NULL,"grp passwd len:%zd\n", ((struct nortelHandle *)gprivdata)->cfg->grppasswd.l);
 	
 	if(generatePresharedKey(
@@ -330,6 +332,8 @@ int cfgXauthUserNameCallback (void *gpri
 	struct isakmp_data *data = NULL;
     
 	plog(LLV_DEBUG, LOCATION, NULL,"==> Enter cfgXauthUserNameCallback...\n");
+	plog(LLV_DEBUG, LOCATION, NULL,"uname len=%zd\n",
+			((struct nortelHandle *)gprivdata)->cfg->uname.l);
 	data = (struct isakmp_data *)malloc(sizeof(struct isakmp_data) + ((struct nortelHandle *)gprivdata)->cfg->uname.l );
 	memset(data,0, sizeof(struct isakmp_data) + ((struct nortelHandle *)gprivdata)->cfg->uname.l ); //to be freed by racoon 
 
Index: novell-nortelplugins-0.1.3/nortel/ike/nortel_nat.c
===================================================================
--- novell-nortelplugins-0.1.3.orig/nortel/ike/nortel_nat.c
+++ novell-nortelplugins-0.1.3/nortel/ike/nortel_nat.c
@@ -71,7 +71,7 @@ nortel_nat_enable_natt (struct nortelHan
       remote.sin_addr.s_addr = gateway_ip;
       client_keepalive_add ( (struct sockaddr *) &iph1->local, (struct sockaddr *) &remote, iph1);
       
-      plog (LLV_ERROR, LOCATION, NULL,
+      plog (LLV_INFO, LOCATION, NULL,
             "Added CLIENT KEEP ALIVE!\n");
 	
    }
openSUSE Build Service is sponsored by