Revamp SSH authentication code so that user interaction is more
[u/mdw/putty] / windows / winsftp.c
index c071257..47d3c43 100644 (file)
@@ -125,6 +125,17 @@ void gui_enable(char *arg)
     gui_hwnd = (HWND) atoi(arg);
 }
 
+char *get_ttymode(void *frontend, const char *mode) { return NULL; }
+
+int get_userpass_input(prompts_t *p, unsigned char *in, int inlen)
+{
+    int ret;
+    ret = cmdline_get_passwd_input(p, in, inlen);
+    if (ret == -1)
+       ret = console_get_userpass_input(p, in, inlen);
+    return ret;
+}
+
 /* ----------------------------------------------------------------------
  * File access abstraction.
  */
@@ -306,20 +317,26 @@ DirHandle *open_directory(char *name)
 
 char *read_filename(DirHandle *dir)
 {
-    while (!dir->name) {
-       WIN32_FIND_DATA fdat;
-       int ok = FindNextFile(dir->h, &fdat);
+    do {
 
-       if (!ok)
-           return NULL;
+       if (!dir->name) {
+           WIN32_FIND_DATA fdat;
+           int ok = FindNextFile(dir->h, &fdat);
+           if (!ok)
+               return NULL;
+           else
+               dir->name = dupstr(fdat.cFileName);
+       }
 
-       if (fdat.cFileName[0] == '.' &&
-           (fdat.cFileName[1] == '\0' ||
-            (fdat.cFileName[1] == '.' && fdat.cFileName[2] == '\0')))
+       assert(dir->name);
+       if (dir->name[0] == '.' &&
+           (dir->name[1] == '\0' ||
+            (dir->name[1] == '.' && dir->name[2] == '\0'))) {
+           sfree(dir->name);
            dir->name = NULL;
-       else
-           dir->name = dupstr(fdat.cFileName);
-    }
+       }
+
+    } while (!dir->name);
 
     if (dir->name) {
        char *ret = dir->name;
@@ -445,6 +462,17 @@ void finish_wildcard_matching(WildcardMatcher *dir)
     sfree(dir);
 }
 
+int vet_filename(char *name)
+{
+    if (strchr(name, '/') || strchr(name, '\\') || strchr(name, ':'))
+       return FALSE;
+
+    if (!name[strspn(name, ".")])      /* entirely composed of dots */
+       return FALSE;
+
+    return TRUE;
+}
+
 int create_directory(char *name)
 {
     return CreateDirectory(name, NULL) != 0;