there a long time. Also, move the tokval buffer from global data
to the stack.
#define ID 10
#define MACH 11
#define ID 10
#define MACH 11
-static char tokval[100];
+#define MAX_TOKVAL_SIZE 1024
struct toktab {
char *tokstr;
struct toktab {
char *tokstr;
+static int token(char *);
if (errno != ENOENT)
perror (credentials_file);
} else {
if (errno != ENOENT)
perror (credentials_file);
} else {
- while ((t = token())) {
+ char tokval[MAX_TOKVAL_SIZE];
+ tokval[0] = '\0';
+
+ while ((t = token(tokval))) {
switch(t) {
case DEFAULT:
usedefault = 1;
switch(t) {
case DEFAULT:
usedefault = 1;
case MACH:
if (!usedefault) {
case MACH:
if (!usedefault) {
+ if (token(tokval) != ID)
continue;
/*
* Allow match either for user's host name.
continue;
/*
* Allow match either for user's host name.
- while ((t = token()) && t != MACH && t != DEFAULT) {
+ while ((t = token(tokval)) && t != MACH && t != DEFAULT) {
- if (token() && *aname == 0) {
+ if (token(tokval) && *aname == 0) {
*aname = mh_xmalloc((size_t) strlen(tokval) + 1);
strcpy(*aname, tokval);
}
*aname = mh_xmalloc((size_t) strlen(tokval) + 1);
strcpy(*aname, tokval);
}
adios(NULL, "Remove password or correct file "
"permissions.");
}
adios(NULL, "Remove password or correct file "
"permissions.");
}
- if (token() && *apass == 0) {
+ if (token(tokval) && *apass == 0) {
*apass = mh_xmalloc((size_t) strlen(tokval) + 1);
strcpy(*apass, tokval);
}
*apass = mh_xmalloc((size_t) strlen(tokval) + 1);
strcpy(*apass, tokval);
}
snprintf(prompt, sizeof(prompt), "Password (%s:%s): ", host, *aname);
mypass = nmh_getpass(prompt);
snprintf(prompt, sizeof(prompt), "Password (%s:%s): ", host, *aname);
mypass = nmh_getpass(prompt);
if (*mypass == '\0') {
mypass = *aname;
}
if (*mypass == '\0') {
mypass = *aname;
}
if (c == '\\')
c = getc(cfile);
*cp++ = c;
if (c == '\\')
c = getc(cfile);
*cp++ = c;
+ if (cp - tokval > MAX_TOKVAL_SIZE-1) {
+ adios(NULL, "credential tokens restricted to length %d",
+ MAX_TOKVAL_SIZE - 1);
+ }
if (c == '\\')
c = getc(cfile);
*cp++ = c;
if (c == '\\')
c = getc(cfile);
*cp++ = c;
+ if (cp - tokval > MAX_TOKVAL_SIZE-1) {
+ adios(NULL, "credential tokens restricted to length %d",
+ MAX_TOKVAL_SIZE - 1);
+ }