Replace a call to 'alloca', thus avoiding an error when compiling on
freebsd/alpha with -ansi (and on some non-fbsd platforms). This change can only affect the access checking of 'lpr -r'. MFC after: 1 week
This commit is contained in:
parent
cda5daf84c
commit
fd41faa7c9
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=79743
@ -698,9 +698,9 @@ static int
|
||||
test(const char *file)
|
||||
{
|
||||
struct exec execb;
|
||||
char *path;
|
||||
register int fd;
|
||||
register char *cp;
|
||||
size_t dlen;
|
||||
int fd;
|
||||
char *cp, *dirpath;
|
||||
|
||||
if (access(file, 4) < 0) {
|
||||
printf("%s: cannot access %s\n", progname, file);
|
||||
@ -732,6 +732,11 @@ test(const char *file)
|
||||
}
|
||||
(void) close(fd);
|
||||
if (rflag) {
|
||||
/*
|
||||
* aside: note that 'cp' is technically a 'const char *'
|
||||
* (because it points into 'file'), even though strrchr
|
||||
* returns a value of type 'char *'.
|
||||
*/
|
||||
if ((cp = strrchr(file, '/')) == NULL) {
|
||||
if (checkwriteperm(file,".") == 0)
|
||||
return(1);
|
||||
@ -739,11 +744,12 @@ test(const char *file)
|
||||
if (cp == file) {
|
||||
fd = checkwriteperm(file,"/");
|
||||
} else {
|
||||
path = alloca(strlen(file) + 1);
|
||||
strcpy(path,file);
|
||||
*cp = '\0';
|
||||
fd = checkwriteperm(path,file);
|
||||
*cp = '/';
|
||||
/* strlcpy will change the '/' to '\0' */
|
||||
dlen = cp - file + 1;
|
||||
dirpath = malloc(dlen);
|
||||
strlcpy(dirpath, file, dlen);
|
||||
fd = checkwriteperm(file, dirpath);
|
||||
free(dirpath);
|
||||
}
|
||||
if (fd == 0)
|
||||
return(1);
|
||||
|
Loading…
Reference in New Issue
Block a user