-/* $Cambridge: exim/src/src/auths/auth-spa.c,v 1.1 2004/10/07 13:10:00 ph10 Exp $ */
+/* $Cambridge: exim/src/src/auths/auth-spa.c,v 1.3 2005/08/02 13:23:19 ph10 Exp $ */
/*************************************************
* Exim - an Internet mail transport agent *
challenge_str = argv [3];
+ if (spa_base64_to_bits ((char *)&challenge, sizeof(challenge),
+ (const char *)(challenge_str))<0)
+ {
+ printf("bad base64 data in challenge: %s\n", challenge_str);
+ exit (1);
+ }
+
spa_build_auth_response (&challenge, &response, username, password);
spa_bits_to_base64 (msgbuf, (unsigned char*)&response,
spa_request_length(&response));
*out = '\0';
}
+
+/* The outlength parameter was added by PH, December 2004 */
+
int
-spa_base64_to_bits (char *out, const char *in)
+spa_base64_to_bits (char *out, int outlength, const char *in)
/* base 64 to raw bytes in quasi-big-endian order, returning count of bytes */
{
int len = 0;
do
{
+ if (len >= outlength) /* Added by PH */
+ return (-1); /* Added by PH */
digit1 = in[0];
if (DECODE64 (digit1) == BAD)
return (-1);
++len;
if (digit3 != '=')
{
+ if (len >= outlength) /* Added by PH */
+ return (-1); /* Added by PH */
*out++ =
((DECODE64 (digit2) << 4) & 0xf0) | (DECODE64 (digit3) >> 2);
++len;
if (digit4 != '=')
{
+ if (len >= outlength) /* Added by PH */
+ return (-1); /* Added by PH */
*out++ = ((DECODE64 (digit3) << 6) & 0xc0) | DECODE64 (digit4);
++len;
}