From 6b069fabe7743a672a6b40d99e74cfd66efc502d Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Tue, 4 Oct 1994 16:56:40 +0000 Subject: [PATCH] now bail if ARgv[1] > MAXPATHLEN --- sudo.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sudo.c b/sudo.c index d2cfeb0d1..7b760ea18 100644 --- a/sudo.c +++ b/sudo.c @@ -586,7 +586,12 @@ static void load_cmnd() { char path[MAXPATHLEN + 1]; - strncpy(path, Argv[1], MAXPATHLEN)[MAXPATHLEN] = 0; + if (strlen(Argv[1]) >= sizeof(path)) { + (void) fprintf(stderr, "%s: %s: Pathname too long\n", Argv[0], Argv[1]); + exit(1); + } + + (void) strcpy(path, Argv[1]); cmnd = find_path(path); /* get the absolute path */ if (cmnd == NULL) {