diff options
author | Fumitoshi UKAI <ukai@debian.or.jp> | 2002-01-30 15:08:48 +0000 |
---|---|---|
committer | Fumitoshi UKAI <ukai@debian.or.jp> | 2002-01-30 15:08:48 +0000 |
commit | 05af6d32e67e92f4bcc21c337acf66c7eb05a3cd (patch) | |
tree | 2859704dfe87fb59093590dab50bc2cc24a1dfee /file.c | |
parent | [w3m-dev 02931] use POST in multipart.cgi (diff) | |
download | w3m-05af6d32e67e92f4bcc21c337acf66c7eb05a3cd.tar.gz w3m-05af6d32e67e92f4bcc21c337acf66c7eb05a3cd.zip |
[w3m-dev 02933] segmentation fault when w3m -dump https:
* file.c (readHeader): use inputAnswer()
* file.c (getAuthCookie): remove term_cbreak()
* file.c (checkOverWrite): use inputAnswer()
* file.c (inputAnswer): added
* istream.c (ssl_get_certificate): use inputAnswer()
* main.c (qquitfm): change prompt
* proto.h (inputAnswer): added
From: Hironori Sakamoto <hsaka@mth.biglobe.ne.jp>
Diffstat (limited to '')
-rw-r--r-- | file.c | 51 |
1 files changed, 30 insertions, 21 deletions
@@ -1,4 +1,4 @@ -/* $Id: file.c,v 1.50 2002/01/30 04:25:02 ukai Exp $ */ +/* $Id: file.c,v 1.51 2002/01/30 15:08:48 ukai Exp $ */ #include "fm.h" #include <sys/types.h> #include "myctype.h" @@ -731,16 +731,14 @@ readHeader(URLFile *uf, Buffer *newBuf, int thru, ParsedURL *pu) ? "y" : NULL; if (fmInitialized && (err & COO_OVERRIDE_OK) && accept_bad_cookie == ACCEPT_BAD_COOKIE_ASK) { - Str msg = - Sprintf - ("Accept bad cookie from %s for %s? (y or n) ", - pu->host, - domain - && domain->ptr ? domain->ptr : "<localdomain>"); - if (msg->length > COLS - 4) - Strshrink(msg, msg->length - (COLS - 4)); - term_raw(); - ans = inputChar(msg->ptr); + Str msg = Sprintf("Accept bad cookie from %s for %s?", + pu->host, + ((domain && domain->ptr) + ? domain->ptr : "<localdomain>")); + if (msg->length > COLS - 10) + Strshrink(msg, msg->length - (COLS - 10)); + Strcat_charp(msg, " (y/n)"); + ans = inputAnswer(msg->ptr); } if (ans == NULL || tolower(*ans) != 'y' || (err = @@ -1222,7 +1220,6 @@ getAuthCookie(struct http_auth *hauth, char *auth_header, IN_PASSWORD)) == NULL) return NULL; pwd = Str_conv_to_system(Strnew_charp(pp)); - term_cbreak(); } else { int proxy = !strncasecmp("Proxy-Authorization:", auth_header, @@ -6393,22 +6390,34 @@ int checkOverWrite(char *path) { struct stat st; - char buf[2]; - char *ans = NULL; + char *ans; if (stat(path, &st) < 0) return 0; + ans = inputAnswer("File exists. Overwrite? (y/n)"); + if (ans && tolower(*ans) == 'y') + return 0; + else + return -1; +} + +char * +inputAnswer(char *prompt) +{ + char *ans; + char buf[2]; + if (fmInitialized) { - ans = inputChar("File exists. Overwrite? (y or n)"); + term_raw(); + ans = inputChar(prompt); } else { - printf("File exists. Overwrite? (y or n)"); - ans = fgets(buf, 2, stdin); + printf(prompt); + fflush(stdout); + fgets(buf, 2, stdin); + ans = allocStr(buf, 1); } - if (ans != NULL && (*ans == '\0' || tolower(*ans) == 'y')) - return 0; - else - return -1; + return ans; } static void |