summaryrefslogtreecommitdiff
path: root/logging.c
diff options
context:
space:
mode:
authorTodd C. Miller <Todd.Miller@courtesan.com>1996-02-02 04:52:30 +0000
committerTodd C. Miller <Todd.Miller@courtesan.com>1996-02-02 04:52:30 +0000
commit73f846567daa24303745c3af36ca3642edc1f920 (patch)
tree5cad1528d9ae6a3459db1b8473567251beb72bc4 /logging.c
parent61730faa30335d03ce0f379aa675fd40b8c30ca0 (diff)
downloadsudo-73f846567daa24303745c3af36ca3642edc1f920.tar.gz
protected against dereferencing rogue pointers
Diffstat (limited to 'logging.c')
-rw-r--r--logging.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/logging.c b/logging.c
index 6520766f1..e513f4348 100644
--- a/logging.c
+++ b/logging.c
@@ -148,8 +148,9 @@ void log_error(code)
* XXX - don't use 33, use a macro!
*/
count = 33 + 128 + 2 * MAXPATHLEN + strlen(tty) + strlen(cwd);
- for (a = &NewArgv[1]; *a; a++)
- count += strlen(*a) + 1;
+ if (NewArgc > 1)
+ for (a = &NewArgv[1]; *a; a++)
+ count += strlen(*a) + 1;
logline = (char *) malloc(count);
if (logline == NULL) {
@@ -288,10 +289,11 @@ void log_error(code)
/* XXX - this could be sped up */
strcat(logline, cmnd);
strcat(logline, " ");
- for (a = &NewArgv[1]; *a; a++) {
- strcat(logline, *a);
- strcat(logline, " ");
- }
+ if (NewArgc > 1)
+ for (a = &NewArgv[1]; *a; a++) {
+ strcat(logline, *a);
+ strcat(logline, " ");
+ }
}
#if (LOGGING & SLOG_SYSLOG)
@@ -550,10 +552,11 @@ void inform_user(code)
"Sorry, user %s is not allowed to execute \"%s",
user_name, cmnd);
- for (a = &NewArgv[1]; *a; a++) {
- fputc(' ', stderr);
- fputs(*a, stderr);
- }
+ if (NewArgc > 1)
+ for (a = &NewArgv[1]; *a; a++) {
+ fputc(' ', stderr);
+ fputs(*a, stderr);
+ }
(void) fprintf(stderr, "\" on %s.\n\n", host);
break;