* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#ifndef lint
-static char rcsid[] = "$Id: chap.c,v 1.20 1999/03/16 22:54:38 paulus Exp $";
-#endif
+#define RCSID "$Id: chap.c,v 1.24 1999/11/15 01:51:50 paulus Exp $"
/*
* TODO:
#include "chap_ms.h"
#endif
+static const char rcsid[] = RCSID;
+
/*
* Command-line options.
*/
rhostname[len] = '\000';
/* Microsoft doesn't send their name back in the PPP packet */
- if (remote_name[0] != 0 && (explicit_remote || rhostname[0] == 0)) {
- strlcpy(rhostname, sizeof(rhostname), remote_name);
+ if (explicit_remote || (remote_name[0] != 0 && rhostname[0] == 0)) {
+ strlcpy(rhostname, remote_name, sizeof(rhostname));
CHAPDEBUG(("ChapReceiveChallenge: using '%q' as remote name",
rhostname));
}
* do the hash ourselves, and compare the result.
*/
code = CHAP_FAILURE;
- if (!get_secret(cstate->unit, rhostname, cstate->chal_name,
- secret, &secret_len, 1)) {
+ if (!get_secret(cstate->unit, (explicit_remote? remote_name: rhostname),
+ cstate->chal_name, secret, &secret_len, 1)) {
warn("No CHAP secret found for authenticating %q", rhostname);
} else {
{
int chal_len;
u_char *ptr = cstate->challenge;
- unsigned int i;
+ int i;
/* pick a random challenge length between MIN_CHALLENGE_LENGTH and
MAX_CHALLENGE_LENGTH */
cstate->chal_transmits = 0;
/* generate a random string */
- for (i = 0; i < chal_len; i++ )
+ for (i = 0; i < chal_len; i++)
*ptr++ = (char) (drand48() * 0xff);
}