protected against dereferencing rogue pointers

This commit is contained in:
Todd C. Miller
1996-02-02 04:52:30 +00:00
parent e06c19bbb9
commit f19b2ebf8d

View File

@@ -148,8 +148,9 @@ void log_error(code)
* XXX - don't use 33, use a macro! * XXX - don't use 33, use a macro!
*/ */
count = 33 + 128 + 2 * MAXPATHLEN + strlen(tty) + strlen(cwd); count = 33 + 128 + 2 * MAXPATHLEN + strlen(tty) + strlen(cwd);
for (a = &NewArgv[1]; *a; a++) if (NewArgc > 1)
count += strlen(*a) + 1; for (a = &NewArgv[1]; *a; a++)
count += strlen(*a) + 1;
logline = (char *) malloc(count); logline = (char *) malloc(count);
if (logline == NULL) { if (logline == NULL) {
@@ -288,10 +289,11 @@ void log_error(code)
/* XXX - this could be sped up */ /* XXX - this could be sped up */
strcat(logline, cmnd); strcat(logline, cmnd);
strcat(logline, " "); strcat(logline, " ");
for (a = &NewArgv[1]; *a; a++) { if (NewArgc > 1)
strcat(logline, *a); for (a = &NewArgv[1]; *a; a++) {
strcat(logline, " "); strcat(logline, *a);
} strcat(logline, " ");
}
} }
#if (LOGGING & SLOG_SYSLOG) #if (LOGGING & SLOG_SYSLOG)
@@ -550,10 +552,11 @@ void inform_user(code)
"Sorry, user %s is not allowed to execute \"%s", "Sorry, user %s is not allowed to execute \"%s",
user_name, cmnd); user_name, cmnd);
for (a = &NewArgv[1]; *a; a++) { if (NewArgc > 1)
fputc(' ', stderr); for (a = &NewArgv[1]; *a; a++) {
fputs(*a, stderr); fputc(' ', stderr);
} fputs(*a, stderr);
}
(void) fprintf(stderr, "\" on %s.\n\n", host); (void) fprintf(stderr, "\" on %s.\n\n", host);
break; break;