From c0b882457d539fd545b732acca186150debec19d Mon Sep 17 00:00:00 2001 From: Johan Danielsson Date: Thu, 6 Nov 1997 22:46:55 +0000 Subject: [PATCH] Move confirmation of suspicious filenames from remglob to mget. git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@3813 ec53bebd-3082-4978-b11e-865c3cabbd6b --- appl/ftp/ftp/cmds.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/appl/ftp/ftp/cmds.c b/appl/ftp/ftp/cmds.c index a5c9b1239..8ae2be523 100644 --- a/appl/ftp/ftp/cmds.c +++ b/appl/ftp/ftp/cmds.c @@ -661,6 +661,12 @@ getit(int argc, char **argv, int restartit, char *mode) return (0); } +static int +suspicious_filename(const char *fn) +{ + return stncmp(fn, "../", 3) == 0 || *fn == '/'; +} + /* * Get multiple files. */ @@ -685,6 +691,8 @@ mget(int argc, char **argv) mflag = 0; continue; } + if (mflag && suspicious_filename(cp)) + printf("*** Suspicious filename: %s\n", cp); if (mflag && confirm(argv[0], cp)) { tp = cp; if (mcase) { @@ -774,15 +782,9 @@ remglob(char **argv, int doswitch) while(fgets(buf, sizeof (buf), ftemp)) { 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); - continue; - } - if(!confirm(buf, *buf == '/' ? - " - retrieve file starting with `/'" : - " - retrieve file starting with `..'")) - continue; + if(!interactive && suspicious_filename(buf)){ + printf("Ignoring remote globbed file `%s'\n", buf); + continue; } return buf; }