diff options
-rw-r--r-- | Str.c | 14 | ||||
-rw-r--r-- | anchor.c | 2 | ||||
-rw-r--r-- | buffer.c | 7 | ||||
-rw-r--r-- | cookie.c | 29 | ||||
-rw-r--r-- | file.c | 6 | ||||
-rw-r--r-- | frame.c | 4 | ||||
-rw-r--r-- | ftp.c | 8 | ||||
-rw-r--r-- | history.c | 7 | ||||
-rw-r--r-- | html.h | 2 | ||||
-rw-r--r-- | istream.c | 2 | ||||
-rw-r--r-- | libwc/iso2022.c | 2 | ||||
-rw-r--r-- | linein.c | 10 | ||||
-rw-r--r-- | local.c | 3 | ||||
-rw-r--r-- | mailcap.c | 2 | ||||
-rw-r--r-- | main.c | 12 | ||||
-rw-r--r-- | menu.c | 1 | ||||
-rw-r--r-- | news.c | 6 | ||||
-rw-r--r-- | rc.c | 2 | ||||
-rw-r--r-- | table.c | 4 | ||||
-rw-r--r-- | terms.c | 2 | ||||
-rw-r--r-- | url.c | 6 | ||||
-rw-r--r-- | w3mbookmark.c | 6 | ||||
-rw-r--r-- | w3mhelperpanel.c | 1 |
23 files changed, 69 insertions, 69 deletions
@@ -530,11 +530,8 @@ Str Strfgets(FILE * f) { Str s = Strnew(); - char c; - while (1) { - c = fgetc(f); - if (feof(f) || ferror(f)) - break; + int c; + while ((c = fgetc(f)) != EOF) { Strcat_char(s, c); if (c == '\n') break; @@ -546,11 +543,8 @@ Str Strfgetall(FILE * f) { Str s = Strnew(); - char c; - while (1) { - c = fgetc(f); - if (feof(f) || ferror(f)) - break; + int c; + while ((c = fgetc(f)) != EOF) { Strcat_char(s, c); } return s; @@ -643,7 +643,6 @@ addMultirowsForm(Buffer *buf, AnchorList *al) { int i, j, k, col, ecol, pos; Anchor a_form, *a; - FormItemList *fi; Line *l, *ls; if (al == NULL || al->nanchor == 0) @@ -670,7 +669,6 @@ addMultirowsForm(Buffer *buf, AnchorList *al) if (!ls) continue; } - fi = (FormItemList *)a_form.url; col = COLPOS(ls, a_form.start.pos); ecol = COLPOS(ls, a_form.end.pos); for (j = 0; l && j < a_form.rows; l = l->next, j++) { @@ -705,6 +705,7 @@ readBufferCache(Buffer *buf) cache = fopen(buf->savecache, "r"); if (cache == NULL || fread1(clnum, cache) || fread1(tlnum, cache)) { + fclose(cache); buf->savecache = NULL; return -1; } @@ -760,8 +761,10 @@ readBufferCache(Buffer *buf) } #endif } - buf->lastLine = prevl; - buf->lastLine->next = NULL; + if (prevl) { + buf->lastLine = prevl; + buf->lastLine->next = NULL; + } fclose(cache); unlink(buf->savecache); buf->savecache = NULL; @@ -22,10 +22,10 @@ static int is_saved = 1; #define contain_no_dots(p, ep) (total_dot_number((p),(ep),1)==0) -static int -total_dot_number(char *p, char *ep, int max_count) +static unsigned int +total_dot_number(char *p, char *ep, unsigned int max_count) { - int count = 0; + unsigned int count = 0; if (!ep) ep = p + strlen(p); @@ -105,6 +105,7 @@ make_portlist(Str port) pl->next = first; first = pl; } + Strfree(tmp); return first; } @@ -324,7 +325,7 @@ add_cookie(ParsedURL *pu, Str name, Str value, if (version == 0) { /* [NETSCAPE] rule */ - int n = total_dot_number(domain->ptr, + unsigned int n = total_dot_number(domain->ptr, domain->ptr + domain->length, 3); if (n < 2) { @@ -517,36 +518,36 @@ load_cookies(void) cookie->commentURL = NULL; parseURL(readcol(&str)->ptr, &cookie->url, NULL); if (!*str) - return; + break; cookie->name = readcol(&str); if (!*str) - return; + break; cookie->value = readcol(&str); if (!*str) - return; + break; cookie->expires = (time_t) atol(readcol(&str)->ptr); if (!*str) - return; + break; cookie->domain = readcol(&str); if (!*str) - return; + break; cookie->path = readcol(&str); if (!*str) - return; + break; cookie->flag = atoi(readcol(&str)->ptr); if (!*str) - return; + break; cookie->version = atoi(readcol(&str)->ptr); if (!*str) - return; + break; cookie->comment = readcol(&str); if (cookie->comment->length == 0) cookie->comment = NULL; if (!*str) - return; + break; cookie->portl = make_portlist(readcol(&str)); if (!*str) - return; + break; cookie->commentURL = readcol(&str); if (cookie->commentURL->length == 0) cookie->commentURL = NULL; @@ -1228,6 +1228,7 @@ AuthDigestCred(struct http_auth *ha, Str uname, Str pw, ParsedURL *pu, unsigned char md5[MD5_DIGEST_LENGTH + 1]; Str uri = HTTPrequestURI(pu, hr); char nc[] = "00000001"; + FILE *fp; Str algorithm = qstr_unquote(get_auth_param(ha->param, "algorithm")); Str nonce = qstr_unquote(get_auth_param(ha->param, "nonce")); @@ -1310,10 +1311,11 @@ AuthDigestCred(struct http_auth *ha, Str uname, Str pw, ParsedURL *pu, /* A2 = Method ":" digest-uri-value ":" H(entity-body) */ if (request && request->body) { if (request->method == FORM_METHOD_POST && request->enctype == FORM_ENCTYPE_MULTIPART) { - FILE *fp = fopen(request->body, "r"); + fp = fopen(request->body, "r"); if (fp != NULL) { Str ebody; ebody = Strfgetall(fp); + fclose(fp); MD5(ebody->ptr, strlen(ebody->ptr), md5); } else { @@ -7206,7 +7208,6 @@ loadHTMLstream(URLFile *f, Buffer *newBuf, FILE * src, int internal) HTMLlineproc0(lineBuf2->ptr, &htmlenv1, internal); } if (obuf.status != R_ST_NORMAL) { - obuf.status = R_ST_EOL; HTMLlineproc0("\n", &htmlenv1, internal); } obuf.status = R_ST_NORMAL; @@ -7403,7 +7404,6 @@ loadBuffer(URLFile *uf, Buffer *volatile newBuf) if (newBuf == NULL) newBuf = newBuffer(INIT_BUFFER_WIDTH); - lineBuf2 = Strnew(); if (SETJMP(AbortLoading) != 0) { goto _end; @@ -895,8 +895,10 @@ renderFrame(Buffer *Cbuf, int force_reload) /* * if (Cbuf->frameQ != NULL) fset = Cbuf->frameQ->frameset; else */ fset = Cbuf->frameset; - if (fset == NULL || createFrameFile(fset, f, Cbuf, 0, force_reload) < 0) + if (fset == NULL || createFrameFile(fset, f, Cbuf, 0, force_reload) < 0) { + fclose(f); return NULL; + } fclose(f); flag = RG_FRAME; if ((Cbuf->currentURL).is_nocache) @@ -123,6 +123,7 @@ static int ftp_login(FTP ftp) { int sock, status; + int sock_wf; sock = openSocket(ftp->host, "ftp", 21); if (sock < 0) @@ -139,7 +140,6 @@ ftp_login(FTP ftp) socklen_t socknamelen = sizeof(sockname); if (!getsockname(sock, (struct sockaddr *)&sockname, &socknamelen)) { - struct hostent *sockent; Str tmp = Strnew_charp(ftp->pass); #ifdef INET6 char hostbuf[NI_MAXHOST]; @@ -156,6 +156,7 @@ ftp_login(FTP ftp) Strcat_charp(tmp, "unknown"); #else + struct hostent *sockent; if ((sockent = gethostbyaddr((char *)&sockname.sin_addr, sizeof(sockname.sin_addr), sockname.sin_family))) @@ -169,7 +170,10 @@ ftp_login(FTP ftp) } } ftp->rf = newInputStream(sock); - ftp->wf = fdopen(dup(sock), "wb"); + if ((sock_wf = dup(sock)) >= 0 ) + ftp->wf = fdopen(sock_wf, "wb"); + else + goto open_err; if (!ftp->rf || !ftp->wf) goto open_err; IStype(ftp->rf) |= IST_UNCLOSE; @@ -60,6 +60,7 @@ saveHistory(Hist *hist, size_t size) FILE *f; HistItem *item; char *tmpf; + int rename_ret; if (hist == NULL || hist->list == NULL) return; @@ -79,7 +80,11 @@ saveHistory(Hist *hist, size_t size) disp_err_message("Can't save history", FALSE); return; } - rename(tmpf, rcFile(HISTORY_FILE)); + rename_ret = rename(tmpf, rcFile(HISTORY_FILE)); + if (rename_ret != 0) { + disp_err_message("Can't save history", FALSE); + return; + } } #endif /* USE_HISTORY */ @@ -12,7 +12,7 @@ #define StrmyUFgets(f) StrmyISgets((f)->stream) #define UFgetc(f) ISgetc((f)->stream) #define UFundogetc(f) ISundogetc((f)->stream) -#define UFclose(f) (void)(ISclose((f)->stream) == 0 && ((f)->stream = NULL)) +#define UFclose(f) if (ISclose((f)->stream) == 0) {(f)->stream = NULL ;} #define UFfileno(f) ISfileno((f)->stream) struct cmdtable { @@ -475,8 +475,6 @@ ssl_check_cert_ident(X509 * x, char *hostname) /* FIXME: gettextize? */ ret = Sprintf("Bad cert ident %s from %s", buf, hostname); } - else - match_ident = TRUE; } return ret; } diff --git a/libwc/iso2022.c b/libwc/iso2022.c index 33d9a19..385adde 100644 --- a/libwc/iso2022.c +++ b/libwc/iso2022.c @@ -463,7 +463,7 @@ wc_push_to_iso2022(Str os, wc_wchar_t cc, wc_status *st) cc.code = (wc_uint32)WC_REPLACE[0]; break; default: - if ((cc.ccs == WC_CCS_JOHAB || WC_CCS_JOHAB_1 || + if ((cc.ccs == WC_CCS_JOHAB || cc.ccs == WC_CCS_JOHAB_1 || cc.ccs == WC_CCS_JOHAB_2 || cc.ccs == WC_CCS_JOHAB_3) && cs94w_gmap[WC_F_KS_X_1001 - WC_F_ISO_BASE]) { wc_wchar_t cc2 = wc_johab_to_ksx1001(cc); @@ -714,7 +714,8 @@ _rdcompl(void) static void next_dcompl(int next) { - static int col, row, len; + static int col, row; + static unsigned int len; static Str d; int i, j, n, y; Str f; @@ -780,9 +781,10 @@ next_dcompl(int next) if (len < n) len = n; } - col = COLS / len; - if (col == 0) - col = 1; + if (len > 0 && COLS > len) + col = COLS / len; + else + col = 1; row = (NCFileBuf + col - 1) / col; disp_next: @@ -168,7 +168,7 @@ loadLocalDir(char *dname) else { #if defined(HAVE_LSTAT) && defined(HAVE_READLINK) if (S_ISLNK(lst.st_mode)) { - if ((l = readlink(fbuf->ptr, lbuf, sizeof(lbuf))) > 0) { + if ((l = readlink(fbuf->ptr, lbuf, sizeof(lbuf) - 1)) > 0) { lbuf[l] = '\0'; Strcat_m_charp(tmp, " -> ", html_quote(conv_from_system(lbuf)), NULL); @@ -433,6 +433,5 @@ localcgi_post(char *uri, char *qstr, FormList *request, char *referer) fprintf(stderr, "execl(\"%s\", \"%s\", NULL): %s\n", file, cgi_basename, strerror(errno)); exit(1); - return NULL; #endif } @@ -72,7 +72,7 @@ searchMailcap(struct mailcap *table, char *type) } static int -matchMailcapAttr(char *p, char *attr, int len, Str *value) +matchMailcapAttr(char *p, char *attr, size_t len, Str *value) { int quoted; char *q = NULL; @@ -1,6 +1,7 @@ /* $Id: main.c,v 1.270 2010/08/24 10:11:51 htrb Exp $ */ #define MAINPROGRAM #include "fm.h" +#include <stdio.h> #include <signal.h> #include <setjmp.h> #include <sys/stat.h> @@ -1266,13 +1267,13 @@ static void dump_source(Buffer *buf) { FILE *f; - char c; + int c; if (buf->sourcefile == NULL) return; f = fopen(buf->sourcefile, "r"); if (f == NULL) return; - while (c = fgetc(f), !feof(f)) { + while ((c = fgetc(f)) != EOF) { putchar(c); } fclose(f); @@ -3071,7 +3072,6 @@ handleMailto(char *url) /* follow HREF link */ DEFUN(followA, GOTO_LINK, "Go to current link") { - Line *l; Anchor *a; ParsedURL u; #ifdef USE_IMAGE @@ -3081,7 +3081,6 @@ DEFUN(followA, GOTO_LINK, "Go to current link") if (Currentbuf->firstLine == NULL) return; - l = Currentbuf->currentLine; #ifdef USE_IMAGE a = retrieveCurrentImg(Currentbuf); @@ -3163,13 +3162,11 @@ bufferA(void) /* view inline image */ DEFUN(followI, VIEW_IMAGE, "View image") { - Line *l; Anchor *a; Buffer *buf; if (Currentbuf->firstLine == NULL) return; - l = Currentbuf->currentLine; a = retrieveCurrentImg(Currentbuf); if (a == NULL) @@ -3419,7 +3416,6 @@ followForm(void) static void _followForm(int submit) { - Line *l; Anchor *a, *a2; char *p; FormItemList *fi, *f2; @@ -3428,7 +3424,6 @@ _followForm(int submit) if (Currentbuf->firstLine == NULL) return; - l = Currentbuf->currentLine; a = retrieveCurrentForm(Currentbuf); if (a == NULL) @@ -3533,7 +3528,6 @@ _followForm(int submit) case FORM_INPUT_BUTTON: do_submit: tmp = Strnew(); - tmp2 = Strnew(); multipart = (fi->parent->method == FORM_METHOD_POST && fi->parent->enctype == FORM_ENCTYPE_MULTIPART); query_from_followform(&tmp, fi, multipart); @@ -361,7 +361,6 @@ geom_menu(Menu *menu, int x, int y, int mselect) if (win_w > COLS) { menu->width = COLS - 2 * FRAME_WIDTH; menu->width -= menu->width % FRAME_WIDTH; - win_w = menu->width + 2 * FRAME_WIDTH; } } menu->x = win_x + FRAME_WIDTH; @@ -76,13 +76,15 @@ news_close(News * news) static int news_open(News * news) { - int sock, status; + int sock, status, fd; sock = openSocket(news->host, "nntp", news->port); if (sock < 0) goto open_err; news->rf = newInputStream(sock); - news->wf = fdopen(dup(sock), "wb"); + if ((fd = dup(sock)) < 0) + goto open_err; + news->wf = fdopen(fd, "wb"); if (!news->rf || !news->wf) goto open_err; IStype(news->rf) |= IST_UNCLOSE; @@ -779,7 +779,7 @@ create_option_search_table() qsort(RC_search_table, RC_table_size, sizeof(struct rc_search_table), (int (*)(const void *, const void *))compare_table); - diff1 = diff2 = 0; + diff2 = 0; for (i = 0; i < RC_table_size - 1; i++) { p = RC_search_table[i].param->name; q = RC_search_table[i + 1].param->name; @@ -429,7 +429,6 @@ visible_length(char *str) char *t, *r2; int amp_len = 0; - t = str; while (*str) { prev_status = status; if (next_status(*str, &status)) { @@ -1691,7 +1690,7 @@ renderTable(struct table *t, int max_width, struct html_feed_environ *h_env) { int i, j, w, r, h; Str renderbuf; - short new_tabwidth[MAXCOL]; + short new_tabwidth[MAXCOL] = { 0 }; #ifdef MATRIX int itr; VEC *newwidth; @@ -3018,7 +3017,6 @@ feed_table_tag(struct table *tbl, char *line, struct table_mode *mode, break; case HTML_TABLE_ALT: id = -1; - w = 0; parsedtag_get_value(tag, ATTR_TID, &id); if (id >= 0 && id < tbl->ntable) { struct table *tbl1 = tbl->tables[id].ptr; @@ -1214,7 +1214,6 @@ addch(char pc) { l_prop *pr; int dest, i; - short *dirty; #ifdef USE_M17N static Str tmp = NULL; char **p; @@ -1236,7 +1235,6 @@ addch(char pc) return; p = ScreenImage[CurLine]->lineimage; pr = ScreenImage[CurLine]->lineprop; - dirty = &ScreenImage[CurLine]->isdirty; #ifndef USE_M17N /* Eliminate unprintables according to * iso-8859-*. @@ -819,7 +819,7 @@ parseURL(char *url, ParsedURL *p_url, ParsedURL *current) /* scheme://user:pass@... */ p_url->user = copyPath(qq, q - 1 - qq, COPYPATH_SPC_IGNORE); p_url->pass = copyPath(q, p - q, COPYPATH_SPC_ALLOW); - q = ++p; + p++; goto analyze_url; } /* scheme://host:port/ */ @@ -832,7 +832,7 @@ parseURL(char *url, ParsedURL *p_url, ParsedURL *current) case '@': /* scheme://user@... */ p_url->user = copyPath(q, p - q, COPYPATH_SPC_IGNORE); - q = ++p; + p++; goto analyze_url; case '\0': /* scheme://host */ @@ -1419,7 +1419,6 @@ HTTPrequest(ParsedURL *pu, ParsedURL *current, HRequest *hr, TextList *extra) { Str tmp; TextListItem *i; - int seen_www_auth = 0; #ifdef USE_COOKIE Str cookie; #endif /* USE_COOKIE */ @@ -1435,7 +1434,6 @@ HTTPrequest(ParsedURL *pu, ParsedURL *current, HRequest *hr, TextList *extra) for (i = extra->first; i != NULL; i = i->next) { if (strncasecmp(i->ptr, "Authorization:", sizeof("Authorization:") - 1) == 0) { - seen_www_auth = 1; #ifdef USE_SSL if (hr->command == HR_COMMAND_CONNECT) continue; diff --git a/w3mbookmark.c b/w3mbookmark.c index fcbad11..a306f26 100644 --- a/w3mbookmark.c +++ b/w3mbookmark.c @@ -79,6 +79,7 @@ print_bookmark_panel(char *bmark, char *url, char *title, char *charset) } } printf("</select>\n"); + fclose(f); } printf(bkmark_src2, html_quote(url), html_quote(title)); } @@ -168,7 +169,10 @@ insert_bookmark(char *bmark, struct parsed_tagarg *data) /* In this case, a new bookmark is appeneded after the bookmark file */ return create_new_bookmark(bmark, section, title, url, "a"); } - f = fopen(bmark, "w"); + if ((f = fopen(bmark, "w")) == NULL) { + printf("\nCannot open bookmark %s\n", bmark); + return FALSE; + } while (tl->nitem) { fputs(popText(tl), f); } diff --git a/w3mhelperpanel.c b/w3mhelperpanel.c index 110794b..96b60a0 100644 --- a/w3mhelperpanel.c +++ b/w3mhelperpanel.c @@ -115,6 +115,7 @@ printMailcapPanel(char *mailcap) printf("</table>\n<input type=submit name=submit value=\"%s\">\n</form>\n\ </body>\n</html>\n", MSG_DOIT); + fclose(f); } void |