Merge branch 'master' into 4.next
[exim.git] / src / src / auths / spa.c
index 378d4f6027d18403a6fe22f8670711f1f48737a7..9c0064ae4a25225b429da84a5534f2b2b986d274 100644 (file)
@@ -2,7 +2,7 @@
 *     Exim - an Internet mail transport agent    *
 *************************************************/
 
-/* Copyright (c) University of Cambridge 1995 - 2009 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
 /* See the file NOTICE for conditions of use and distribution. */
 
 /* This file, which provides support for Microsoft's Secure Password
@@ -71,6 +71,19 @@ auth_spa_options_block auth_spa_option_defaults = {
 };
 
 
+#ifdef MACRO_PREDEF
+
+/* Dummy values */
+void auth_spa_init(auth_instance *ablock) {}
+int auth_spa_server(auth_instance *ablock, uschar *data) {return 0;}
+int auth_spa_client(auth_instance *ablock, smtp_inblock *inblock,
+  smtp_outblock *outblock, int timeout, uschar *buffer, int buffsize) {return 0;}
+
+#else   /*!MACRO_PREDEF*/
+
+
+
+
 /*************************************************
 *          Initialization entry point            *
 *************************************************/
@@ -110,7 +123,7 @@ ablock->server = ob->spa_serverpassword != NULL;
 
 /* For interface, see auths/README */
 
-#define CVAL(buf,pos) (((unsigned char *)(buf))[pos])
+#define CVAL(buf,pos) ((US (buf))[pos])
 #define PVAL(buf,pos) ((unsigned)CVAL(buf,pos))
 #define SVAL(buf,pos) (PVAL(buf,pos)|PVAL(buf,(pos)+1)<<8)
 #define IVAL(buf,pos) (SVAL(buf,pos)|SVAL(buf,(pos)+2)<<16)
@@ -138,7 +151,7 @@ if ((*data == '\0') &&
   return FAIL;
   }
 
-if (spa_base64_to_bits((char *)(&request), sizeof(request), (const char *)(data)) < 0)
+if (spa_base64_to_bits(CS (&request), sizeof(request), CCS (data)) < 0)
   {
   DEBUG(D_auth) debug_printf("auth_spa_server(): bad base64 data in "
   "request: %s\n", data);
@@ -158,7 +171,7 @@ if (auth_get_no64_data(&data, msgbuf) != OK)
   }
 
 /* dump client response */
-if (spa_base64_to_bits((char *)(&response), sizeof(response), (const char *)(data)) < 0)
+if (spa_base64_to_bits(CS (&response), sizeof(response), CCS (data)) < 0)
   {
   DEBUG(D_auth) debug_printf("auth_spa_server(): bad base64 data in "
   "response: %s\n", data);
@@ -311,7 +324,7 @@ if (smtp_write_command(outblock, SCMD_FLUSH, "AUTH %s\r\n",
   return FAIL_SEND;
 
 /* wait for the 3XX OK message */
-if (!smtp_read_response(inblock, (uschar *)buffer, buffsize, '3', timeout))
+if (!smtp_read_response(inblock, US buffer, buffsize, '3', timeout))
   return FAIL;
 
 DSPA("\n\n%s authenticator: using domain %s\n\n", ablock->name, domain);
@@ -327,12 +340,12 @@ if (smtp_write_command(outblock, SCMD_FLUSH, "%s\r\n", msgbuf) < 0)
   return FAIL_SEND;
 
 /* wait for the auth challenge */
-if (!smtp_read_response(inblock, (uschar *)buffer, buffsize, '3', timeout))
+if (!smtp_read_response(inblock, US buffer, buffsize, '3', timeout))
   return FAIL;
 
 /* convert the challenge into the challenge struct */
 DSPA("\n\n%s authenticator: challenge (%s)\n\n", ablock->name, buffer + 4);
-spa_base64_to_bits ((char *)(&challenge), sizeof(challenge), (const char *)(buffer + 4));
+spa_base64_to_bits (CS (&challenge), sizeof(challenge), CCS (buffer + 4));
 
 spa_build_auth_response (&challenge, &response, CS username, CS password);
 spa_bits_to_base64 (US msgbuf, (unsigned char*)&response,
@@ -360,4 +373,5 @@ if (errno != 0 || buffer[0] != '3')
 return FAIL;
 }
 
+#endif   /*!MACRO_PREDEF*/
 /* End of spa.c */