Fix DKIM verify when used with CHUNKING. Bug 2016
[exim.git] / src / src / auths / spa.c
index 5647b0c1fa04a2ee913b4c3a21f6dbf0cd462ef2..4d435a411cd03338269bf87ea4e0d46614bf407f 100644 (file)
@@ -1,5 +1,3 @@
-/* $Cambridge: exim/src/src/auths/spa.c,v 1.11 2010/06/05 10:16:36 pdp Exp $ */
-
 /*************************************************
 *     Exim - an Internet mail transport agent    *
 *************************************************/
@@ -63,7 +61,7 @@ address can appear in the tables drtables.c. */
 int auth_spa_options_count =
   sizeof(auth_spa_options)/sizeof(optionlist);
 
-/* Default private options block for the contidion authentication method. */
+/* Default private options block for the condition authentication method. */
 
 auth_spa_options_block auth_spa_option_defaults = {
   NULL,              /* spa_password */
@@ -198,9 +196,11 @@ that causes failure if the size of msgbuf is exceeded. ****/
 /***************************************************************/
 
 /* Put the username in $auth1 and $1. The former is now the preferred variable;
-the latter is the original variable. */
+the latter is the original variable. These have to be out of stack memory, and
+need to be available once known even if not authenticated, for error messages
+(server_set_id, which only makes it to authenticated_id if we return OK) */
 
-auth_vars[0] = expand_nstring[1] = msgbuf;
+auth_vars[0] = expand_nstring[1] = string_copy(msgbuf);
 expand_nlength[1] = Ustrlen(msgbuf);
 expand_nmax = 1;
 
@@ -236,9 +236,11 @@ if (memcmp(ntRespData,
       ((unsigned char*)responseptr)+IVAL(&responseptr->ntResponse.offset,0),
       24) == 0)
   /* success. we have a winner. */
+  {
+  return auth_check_serv_cond(ablock);
+  }
 
   /* Expand server_condition as an authorization check (PH) */
-  return auth_check_serv_cond(ablock);
 
 return FAIL;
 }