X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=cmds.c;h=9e1edcaa80827177bb1aade3446fe9c013390dd7;hb=66307dc43142bd5233b2af5dfe0eaf190657bc24;hp=629d11411156082cea5cad865e077f1ab67ed906;hpb=f804d7afd8445e3ff2f6f4b1e28f20819354e709;p=betaftpd diff --git a/cmds.c b/cmds.c index 629d114..9e1edca 100644 --- a/cmds.c +++ b/cmds.c @@ -1856,7 +1856,16 @@ int prepare_for_listing(struct conn * const c, char ** const ptr, } /* if no argument, choose all files */ - if (fptr == NULL || fptr[0] == 0) fptr = "*"; + if (fptr == NULL || fptr[0] == 0) { + fptr = "*"; + } else { + /* we need to check if the last part is a directory (no -d switch) */ + struct stat buf; + if (stat(fptr, &buf) == 0 && S_ISDIR(buf.st_mode)) { + TRAP_ERROR(chdir(fptr) == -1, 550, return -1); + fptr = "*"; + } + } *ptr = fptr; #if WANT_NONROOT