diff options
Diffstat (limited to 'src/htscore.c')
-rw-r--r-- | src/htscore.c | 92 |
1 files changed, 42 insertions, 50 deletions
diff --git a/src/htscore.c b/src/htscore.c index 70d4fbf..629d3f6 100644 --- a/src/htscore.c +++ b/src/htscore.c @@ -162,7 +162,7 @@ RUN_CALLBACK0(opt, end); \ if (opt->log != NULL) fflush(opt->log); \ if (makestat_fp) { fclose(makestat_fp); makestat_fp=NULL; } \ if (maketrack_fp){ fclose(maketrack_fp); maketrack_fp=NULL; } \ - if (opt->accept_cookie) cookie_save(opt->cookie,fconcat(OPT_GET_BUFF(opt),StringBuff(opt->path_log),"cookies.txt")); \ + if (opt->accept_cookie) cookie_save(opt->cookie,fconcat(OPT_GET_BUFF(opt),OPT_GET_BUFF_SIZE(opt),StringBuff(opt->path_log),"cookies.txt")); \ if (makeindex_fp) { fclose(makeindex_fp); makeindex_fp=NULL; } \ if (cache_hashtable) { inthash_delete(&cache_hashtable); } \ if (cache_tests) { inthash_delete(&cache_tests); } \ @@ -236,8 +236,7 @@ if (makeindex_fp) { \ char BIGSTK tempo[1024]; \ if (makeindex_links == 1) { \ char BIGSTK link_escaped[HTS_URLMAXSIZE*2]; \ - strcpybuff(link_escaped, makeindex_firstlink); \ - escape_uri_utf(link_escaped); \ + escape_uri_utf(makeindex_firstlink, link_escaped, sizeof(link_escaped)); \ sprintf(tempo,"<meta HTTP-EQUIV=\"Refresh\" CONTENT=\"0; URL=%s\">"CRLF, link_escaped); \ } else \ tempo[0]='\0'; \ @@ -248,7 +247,7 @@ if (makeindex_fp) { \ fflush(makeindex_fp); \ fclose(makeindex_fp); /* à ne pas oublier sinon on passe une nuit blanche */ \ makeindex_fp=NULL; \ - usercommand(opt,0,NULL,fconcat(OPT_GET_BUFF(opt),StringBuff(opt->path_html_utf8),"index.html"),"",""); \ + usercommand(opt,0,NULL,fconcat(OPT_GET_BUFF(opt),OPT_GET_BUFF_SIZE(opt),StringBuff(opt->path_html_utf8),"index.html"),"",""); \ } \ } \ makeindex_done=1; /* ok c'est fait */ \ @@ -369,15 +368,15 @@ int httpmirror(char *url1, httrackp * opt) { // et templates html template_header = readfile_or(fconcat - (OPT_GET_BUFF(opt), StringBuff(opt->path_bin), + (OPT_GET_BUFF(opt), OPT_GET_BUFF_SIZE(opt), StringBuff(opt->path_bin), "templates/index-header.html"), HTS_INDEX_HEADER); template_body = readfile_or(fconcat - (OPT_GET_BUFF(opt), StringBuff(opt->path_bin), + (OPT_GET_BUFF(opt), OPT_GET_BUFF_SIZE(opt), StringBuff(opt->path_bin), "templates/index-body.html"), HTS_INDEX_BODY); template_footer = readfile_or(fconcat - (OPT_GET_BUFF(opt), StringBuff(opt->path_bin), + (OPT_GET_BUFF(opt), OPT_GET_BUFF_SIZE(opt), StringBuff(opt->path_bin), "templates/index-footer.html"), HTS_INDEX_FOOTER); // initialiser mimedefs @@ -628,8 +627,8 @@ int httpmirror(char *url1, httrackp * opt) { // lien primaire liens_record("primary", "/primary", - fslash(OPT_GET_BUFF(opt), - fconcat(OPT_GET_BUFF(opt), + fslash(OPT_GET_BUFF(opt), OPT_GET_BUFF_SIZE(opt), + fconcat(OPT_GET_BUFF(opt), OPT_GET_BUFF_SIZE(opt), StringBuff(opt->path_html_utf8), "index.html")), "", "", opt->urlhack); if (liens[lien_tot] == NULL) { // erreur, pas de place réservée @@ -700,7 +699,7 @@ int httpmirror(char *url1, httrackp * opt) { if (opt->makestat) { makestat_fp = fopen(fconcat - (OPT_GET_BUFF(opt), StringBuff(opt->path_log), "hts-stats.txt"), + (OPT_GET_BUFF(opt), OPT_GET_BUFF_SIZE(opt), StringBuff(opt->path_log), "hts-stats.txt"), "wb"); if (makestat_fp != NULL) { fprintf(makestat_fp, "HTTrack statistics report, every minutes" LF LF); @@ -711,7 +710,7 @@ int httpmirror(char *url1, httrackp * opt) { if (opt->maketrack) { maketrack_fp = fopen(fconcat - (OPT_GET_BUFF(opt), StringBuff(opt->path_log), "hts-track.txt"), + (OPT_GET_BUFF(opt), OPT_GET_BUFF_SIZE(opt), StringBuff(opt->path_log), "hts-track.txt"), "wb"); if (maketrack_fp != NULL) { fprintf(maketrack_fp, "HTTrack tracking report, every minutes" LF LF); @@ -1452,7 +1451,7 @@ int httpmirror(char *url1, httrackp * opt) { /* Remove file if being processed */ if (is_loaded_from_file) { - (void) unlink(fconv(OPT_GET_BUFF(opt), savename)); + (void) unlink(fconv(OPT_GET_BUFF(opt), OPT_GET_BUFF_SIZE(opt), savename)); is_loaded_from_file = 0; } @@ -1783,7 +1782,7 @@ int httpmirror(char *url1, httrackp * opt) { #ifndef _WIN32 chmod(tempo, HTS_ACCESS_FILE); #endif - usercommand(opt, 0, NULL, fconv(OPT_GET_BUFF(opt), tempo), "", + usercommand(opt, 0, NULL, fconv(OPT_GET_BUFF(opt), OPT_GET_BUFF_SIZE(opt), tempo), "", ""); } @@ -1979,42 +1978,42 @@ int httpmirror(char *url1, httrackp * opt) { XH_uninit; if ((fexist (fconcat - (OPT_GET_BUFF(opt), StringBuff(opt->path_log), "hts-cache/old.dat"))) + (OPT_GET_BUFF(opt), OPT_GET_BUFF_SIZE(opt), StringBuff(opt->path_log), "hts-cache/old.dat"))) && (fexist (fconcat - (OPT_GET_BUFF(opt), StringBuff(opt->path_log), + (OPT_GET_BUFF(opt), OPT_GET_BUFF_SIZE(opt), StringBuff(opt->path_log), "hts-cache/old.ndx")))) { remove(fconcat - (OPT_GET_BUFF(opt), StringBuff(opt->path_log), + (OPT_GET_BUFF(opt), OPT_GET_BUFF_SIZE(opt), StringBuff(opt->path_log), "hts-cache/new.dat")); remove(fconcat - (OPT_GET_BUFF(opt), StringBuff(opt->path_log), + (OPT_GET_BUFF(opt), OPT_GET_BUFF_SIZE(opt), StringBuff(opt->path_log), "hts-cache/new.ndx")); remove(fconcat - (OPT_GET_BUFF(opt), StringBuff(opt->path_log), + (OPT_GET_BUFF(opt), OPT_GET_BUFF_SIZE(opt), StringBuff(opt->path_log), "hts-cache/new.lst")); remove(fconcat - (OPT_GET_BUFF(opt), StringBuff(opt->path_log), + (OPT_GET_BUFF(opt), OPT_GET_BUFF_SIZE(opt), StringBuff(opt->path_log), "hts-cache/new.txt")); rename(fconcat - (OPT_GET_BUFF(opt), StringBuff(opt->path_log), - "hts-cache/old.dat"), fconcat(OPT_GET_BUFF(opt), + (OPT_GET_BUFF(opt), OPT_GET_BUFF_SIZE(opt), StringBuff(opt->path_log), + "hts-cache/old.dat"), fconcat(OPT_GET_BUFF(opt), OPT_GET_BUFF_SIZE(opt), StringBuff(opt->path_log), "hts-cache/new.dat")); rename(fconcat - (OPT_GET_BUFF(opt), StringBuff(opt->path_log), - "hts-cache/old.ndx"), fconcat(OPT_GET_BUFF(opt), + (OPT_GET_BUFF(opt), OPT_GET_BUFF_SIZE(opt), StringBuff(opt->path_log), + "hts-cache/old.ndx"), fconcat(OPT_GET_BUFF(opt), OPT_GET_BUFF_SIZE(opt), StringBuff(opt->path_log), "hts-cache/new.ndx")); rename(fconcat - (OPT_GET_BUFF(opt), StringBuff(opt->path_log), - "hts-cache/old.lst"), fconcat(OPT_GET_BUFF(opt), + (OPT_GET_BUFF(opt), OPT_GET_BUFF_SIZE(opt), StringBuff(opt->path_log), + "hts-cache/old.lst"), fconcat(OPT_GET_BUFF(opt), OPT_GET_BUFF_SIZE(opt), StringBuff(opt->path_log), "hts-cache/new.lst")); rename(fconcat - (OPT_GET_BUFF(opt), StringBuff(opt->path_log), - "hts-cache/old.txt"), fconcat(OPT_GET_BUFF(opt), + (OPT_GET_BUFF(opt), OPT_GET_BUFF_SIZE(opt), StringBuff(opt->path_log), + "hts-cache/old.txt"), fconcat(OPT_GET_BUFF(opt), OPT_GET_BUFF_SIZE(opt), StringBuff(opt->path_log), "hts-cache/new.txt")); } @@ -2038,16 +2037,16 @@ int httpmirror(char *url1, httrackp * opt) { // old_lst = fopen(fconcat - (OPT_GET_BUFF(opt), StringBuff(opt->path_log), + (OPT_GET_BUFF(opt), OPT_GET_BUFF_SIZE(opt), StringBuff(opt->path_log), "hts-cache/old.lst"), "rb"); if (old_lst) { off_t sz = fsize(fconcat - (OPT_GET_BUFF(opt), StringBuff(opt->path_log), + (OPT_GET_BUFF(opt), OPT_GET_BUFF_SIZE(opt), StringBuff(opt->path_log), "hts-cache/new.lst")); new_lst = fopen(fconcat - (OPT_GET_BUFF(opt), StringBuff(opt->path_log), + (OPT_GET_BUFF(opt), OPT_GET_BUFF_SIZE(opt), StringBuff(opt->path_log), "hts-cache/new.lst"), "rb"); if ((new_lst) && (sz > 0)) { char *adr = (char *) malloct(sz); @@ -2849,10 +2848,10 @@ int filenote(filenote_strc * strc, const char *s, filecreate_params * params) { char BIGSTK savelst[HTS_URLMAXSIZE * 2]; char catbuff[CATBUFF_SIZE]; - strcpybuff(savelst, fslash(catbuff, s)); + strcpybuff(savelst, fslash(catbuff, sizeof(catbuff), s)); // couper chemin? if (strnotempty(strc->path)) { - if (strncmp(fslash(catbuff, strc->path), savelst, strlen(strc->path)) == 0) { // couper + if (strncmp(fslash(catbuff, sizeof(catbuff), strc->path), savelst, strlen(strc->path)) == 0) { // couper strcpybuff(savelst, s + strlen(strc->path)); } } @@ -2938,8 +2937,9 @@ static void postprocess_file(httrackp * opt, const char *save, const char *adr, if (rsc_fil == NULL) rsc_fil = fil; if (strncmp - (fslash(OPT_GET_BUFF(opt), save), - fslash(OPT_GET_BUFF(opt), StringBuff(opt->path_html_utf8)), (n = + (fslash(OPT_GET_BUFF(opt), OPT_GET_BUFF_SIZE(opt), save), + fslash(OPT_GET_BUFF(opt), OPT_GET_BUFF_SIZE(opt), + StringBuff(opt->path_html_utf8)), (n = (int) strlen (StringBuff @@ -2953,13 +2953,15 @@ static void postprocess_file(httrackp * opt, const char *save, const char *adr, //first = 1; opt->state.mimefp = fopen(fconcat - (OPT_GET_BUFF(opt), StringBuff(opt->path_html), "index.mht"), + (OPT_GET_BUFF(opt), OPT_GET_BUFF_SIZE(opt), + StringBuff(opt->path_html), "index.mht"), "wb"); - (void) unlink(fconcat(OPT_GET_BUFF(opt), StringBuff(opt->path_html), + (void) unlink(fconcat(OPT_GET_BUFF(opt), OPT_GET_BUFF_SIZE(opt), + StringBuff(opt->path_html), "index.eml")); #ifndef _WIN32 if (symlink("index.mht", - fconcat(OPT_GET_BUFF(opt), StringBuff(opt->path_html), + fconcat(OPT_GET_BUFF(opt), OPT_GET_BUFF_SIZE(opt), StringBuff(opt->path_html), "index.eml")) != 0) { if (errno != EPERM) { hts_log_print(opt, LOG_WARNING | LOG_ERRNO, @@ -3005,17 +3007,7 @@ static void postprocess_file(httrackp * opt, const char *save, const char *adr, mimebuff[0] = '\0'; /* CID */ - strcpybuff(cid, adr); - strcatbuff(cid, fil); - escape_in_url(cid); - { - char *a = cid; - - while((a = strchr(a, '%'))) { - *a = 'X'; - a++; - } - } + make_content_id(adr, fil, cid, sizeof(cid)); guess_httptype(opt, mimebuff, save); fprintf(opt->state.mimefp, "--%s\r\n", @@ -3323,7 +3315,7 @@ int check_sockerror(T_SOC s) { FD_SET((T_SOC) s, &fds); tv.tv_sec = 0; tv.tv_usec = 0; - select(s + 1, NULL, NULL, &fds, &tv); + select((int) s + 1, NULL, NULL, &fds, &tv); return FD_ISSET(s, &fds); } @@ -3336,7 +3328,7 @@ int check_sockdata(T_SOC s) { FD_SET((T_SOC) s, &fds); tv.tv_sec = 0; tv.tv_usec = 0; - select(s + 1, &fds, NULL, NULL, &tv); + select((int) s + 1, &fds, NULL, NULL, &tv); return FD_ISSET(s, &fds); } |