diff options
author | Xavier Roche <xroche@users.noreply.github.com> | 2014-07-17 19:30:53 +0000 |
---|---|---|
committer | Xavier Roche <xroche@users.noreply.github.com> | 2014-07-17 19:30:53 +0000 |
commit | b5e08a830052c592a33cd889777564f9ea784fd6 (patch) | |
tree | 3964b8b789156e4fa57187b13ca2fff150c0728c | |
parent | 1d2d42eb4e02292016f30101fd40a4f0c38ead50 (diff) |
Fixed infamous crashes inside the DNS cache due to a corruption within the option structure (E.Kalinowski)
This long-lasting bug was a real pain to hunt! :)
-rw-r--r-- | src/htstools.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/htstools.c b/src/htstools.c index a00ce76..adf79ac 100644 --- a/src/htstools.c +++ b/src/htstools.c @@ -536,21 +536,20 @@ void longfile_to_83(int mode, char *n83, char *save) { // écrire backblue.gif /* Note: utf-8 */ int verif_backblue(httrackp * opt, const char *base) { - int *done = &opt->state.verif_backblue_done; int ret = 0; // if (!base) { // init - *done = 0; + opt->state.verif_backblue_done = 0; return 0; } - if ((!*done) + if ((!opt->state.verif_backblue_done) || (fsize_utf8(fconcat(OPT_GET_BUFF(opt), OPT_GET_BUFF_SIZE(opt), base, "backblue.gif")) != HTS_DATA_BACK_GIF_LEN)) { FILE *fp = filecreate(&opt->state.strc, fconcat(OPT_GET_BUFF(opt), OPT_GET_BUFF_SIZE(opt), base, "backblue.gif")); - *done = 1; + opt->state.verif_backblue_done = 1; if (fp) { if (fwrite(HTS_DATA_BACK_GIF, HTS_DATA_BACK_GIF_LEN, 1, fp) != HTS_DATA_BACK_GIF_LEN) @@ -579,12 +578,12 @@ int verif_backblue(httrackp * opt, const char *base) { // flag int verif_external(httrackp * opt, int nb, int test) { - int *status = &opt->state.verif_external_status; - + const int flag = 1 << nb; + int *const status = &opt->state.verif_external_status; if (!test) - status[nb] = 0; // reset - else if (!status[nb]) { - status[nb] = 1; + *status &= ~flag; // reset + else if ((*status & flag) == 0) { + *status |= flag; return 1; } return 0; |