Don't retrieve files that start with ..' or /' without asking.

Reverse test in confirm() to check for `y' rather than not `n'.  Use
mkstemp.


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@3807 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Johan Danielsson
1997-11-06 19:44:24 +00:00
parent 773d8d8a06
commit 6ed1298d81

View File

@@ -562,10 +562,12 @@ int
getit(int argc, char **argv, int restartit, char *mode)
{
int loc = 0;
int local_given = 1;
char *oldargv1, *oldargv2;
if (argc == 2) {
argc++;
local_given = 0;
argv[2] = argv[1];
loc++;
}
@@ -656,7 +658,7 @@ usage:
}
recvrequest("RETR", argv[2], argv[1], mode,
argv[1] != oldargv1 || argv[2] != oldargv2, argv[2] != NULL);
argv[1] != oldargv1 || argv[2] != oldargv2, local_given);
restart_point = 0;
return (0);
}
@@ -745,8 +747,14 @@ remglob(char **argv, int doswitch)
return (cp);
}
if (ftemp == NULL) {
int fd;
strcpy(temp, _PATH_TMP_XXX);
mktemp(temp);
fd = mkstemp(temp);
if(fd < 0){
warn("unable to create temporary file %s", temp);
return NULL;
}
close(fd);
oldverbose = verbose, verbose = 0;
oldhash = hash, hash = 0;
if (doswitch) {
@@ -765,6 +773,7 @@ remglob(char **argv, int doswitch)
return (NULL);
}
}
next:
if (fgets(buf, sizeof (buf), ftemp) == NULL) {
fclose(ftemp);
ftemp = NULL;
@@ -772,6 +781,16 @@ remglob(char **argv, int doswitch)
}
if ((cp = strchr(buf, '\n')) != NULL)
*cp = '\0';
if(strncmp(buf, "../", 3) == 0 || *buf == '/'){
if(interactive == 0){
printf("Ignoring remote globbed file `%s'\n", buf);
goto next;
}
if(!confirm(buf, *buf == '/' ?
" - retrieve file starting with `/'" :
" - retrieve file starting with `..'"))
goto next;
}
return (buf);
}
@@ -1484,7 +1503,7 @@ confirm(char *cmd, char *file)
fflush(stdout);
if (fgets(line, sizeof line, stdin) == NULL)
return (0);
return (*line != 'n' && *line != 'N');
return (*line == 'y' || *line == 'Y');
}
void