[Openswan dev] [patch] xauth: allow username and password to contain spaces.

Dustin Lang dstn at cs.toronto.edu
Thu Aug 3 19:51:58 CEST 2006


Hi,

My XAUTH username has a space in it.  The attached patch makes it work.

Cheers,
dstn.
-------------- next part --------------
diff -r -u openswan-2.4.6rc5-orig/programs/pluto/xauth.c openswan-2.4.6rc5/programs/pluto/xauth.c
--- openswan-2.4.6rc5-orig/programs/pluto/xauth.c	2005-07-25 22:11:23.000000000 -0400
+++ openswan-2.4.6rc5/programs/pluto/xauth.c	2006-08-03 18:36:53.718286180 -0400
@@ -1806,10 +1806,12 @@
 			loglog(RC_LOG_SERIOUS, "XAUTH username prompt failed.");
 			return STF_FAIL;
 		    }
-		    /* trip any trailing white space */
+
+		    /* replace the first newline character with a string-terminating \0. */
 		    {
-		      char *u = xauth_username;
-		      strsep(&u, " \n\t");
+			char* cptr = memchr(xauth_username, '\n', sizeof(xauth_username));
+			if (cptr)
+			    *cptr = '\0';
 		    }
 		    out_raw(xauth_username, strlen(xauth_username)
 			    ,&attrval, "XAUTH username");
@@ -1835,11 +1837,11 @@
 			return STF_FAIL;
 		    }
 
-		    /* trip any trailing white space */
+		    /* replace the first newline character with a string-terminating \0. */
 		    {
-		      char *u = xauth_password;
-
-		      strsep(&u, " \n\t");
+			char* cptr = memchr(xauth_password, '\n', sizeof(xauth_password));
+			if (cptr)
+			    *cptr = '\0';
 		    }
 		    out_raw(xauth_password, strlen(xauth_password)
 			    ,&attrval, "XAUTH password");


More information about the Dev mailing list