2004-03-01 Roland McGrath <roland@redhat.com>
* strace.c (main): Avoid potential buffer overruns from ludicrous arguments or PATH values.
This commit is contained in:
parent
801bf1ff33
commit
bdb09df186
10
strace.c
10
strace.c
@ -417,8 +417,14 @@ char *argv[];
|
|||||||
char pathname[MAXPATHLEN];
|
char pathname[MAXPATHLEN];
|
||||||
|
|
||||||
filename = argv[optind];
|
filename = argv[optind];
|
||||||
if (strchr(filename, '/'))
|
if (strchr(filename, '/')) {
|
||||||
|
if (strlen(filename) > sizeof pathname - 1) {
|
||||||
|
errno = ENAMETOOLONG;
|
||||||
|
perror("strace: exec");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
strcpy(pathname, filename);
|
strcpy(pathname, filename);
|
||||||
|
}
|
||||||
#ifdef USE_DEBUGGING_EXEC
|
#ifdef USE_DEBUGGING_EXEC
|
||||||
/*
|
/*
|
||||||
* Debuggers customarily check the current directory
|
* Debuggers customarily check the current directory
|
||||||
@ -443,6 +449,8 @@ char *argv[];
|
|||||||
getcwd(pathname, MAXPATHLEN);
|
getcwd(pathname, MAXPATHLEN);
|
||||||
len = strlen(pathname);
|
len = strlen(pathname);
|
||||||
}
|
}
|
||||||
|
else if (n > sizeof pathname - 1)
|
||||||
|
continue;
|
||||||
else {
|
else {
|
||||||
strncpy(pathname, path, n);
|
strncpy(pathname, path, n);
|
||||||
len = n;
|
len = n;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user