diff --git a/imapinterface.c b/imapinterface.c index 7d09517..49157a5 100644 --- a/imapinterface.c +++ b/imapinterface.c @@ -1,7 +1,9 @@ #include #include +#ifdef USE_OPENSSL #include #include +#endif #include "imapinterface.h" #include "imap.h" #include "mairix.h" diff --git a/mairix.c b/mairix.c index d52a20d..357707f 100644 --- a/mairix.c +++ b/mairix.c @@ -461,6 +461,7 @@ static void usage(void)/*{{{*/ "-t : include all messages in same threads as matching messages\n" "-o : override setting of mfolder from mairixrc file\n" "-r : force raw output regardless of mformat setting in mairixrc file\n" + "--no-lock : skip database locking when searching\n" "-H : force hard links rather than symbolic ones\n" "expr_i : search expression (all expr's AND'ed together):\n" " word : match word in message body and major headers\n" @@ -537,6 +538,7 @@ int main (int argc, char **argv)/*{{{*/ int do_fast_index = 0; int do_mbox_symlinks = 0; struct imap_ll *imapc = NULL; + int do_not_lock = 0; unsigned int forced_hash_key = CREATE_RANDOM_DATABASE_HASH; @@ -583,6 +585,8 @@ int main (int argc, char **argv)/*{{{*/ do_integrity_checks = 0; } else if (!strcmp(*argv, "--unlock")) { do_forced_unlock = 1; + } else if (!strcmp(*argv, "--no-lock")) { + do_not_lock = 1; } else if (!strcmp(*argv, "-F") || !strcmp(*argv, "--fast-index")) { do_fast_index = 1; @@ -605,11 +609,14 @@ int main (int argc, char **argv)/*{{{*/ } else if (!strcmp(*argv, "-h") || !strcmp(*argv, "--help")) { do_help = 1; - } else if ((*argv)[0] == '-') { - fprintf(stderr, "Unrecognized option %s\n", *argv); } else if (!strcmp(*argv, "--")) { /* End of args */ + argc--; + argv++; break; + } else if ((*argv)[0] == '-') { + fprintf(stderr, "Unrecognized option %s\n", *argv); + exit(3); } else { /* standard args start */ break; @@ -699,7 +706,13 @@ int main (int argc, char **argv)/*{{{*/ signal(SIGINT, handlesig); signal(SIGQUIT, handlesig); - lock_database(database_path, do_forced_unlock); + if (do_not_lock && !do_search) { + fprintf(stderr, "Using --no-lock only permitted for searching\n"); + exit(2); + } + + if (!do_not_lock) + lock_database(database_path, do_forced_unlock); if (do_dump) { dump_database(database_path); diff --git a/nvp.c b/nvp.c index 6a06794..acf8a70 100644 --- a/nvp.c +++ b/nvp.c @@ -52,6 +52,14 @@ struct nvp {/*{{{*/ /*}}}*/ static void append(struct nvp *nvp, struct nvp_entry *ne)/*{{{*/ { + if (!ne->rhs) { + ne->rhs = Malloc(1); + ne->rhs[0] = 0; + } + if (!ne->lhs) { + ne->lhs = Malloc(1); + ne->lhs[0] = 0; + } ne->next = NULL; ne->prev = nvp->last; if (nvp->last) nvp->last->next = ne; @@ -203,21 +211,21 @@ struct nvp *make_nvp(struct msg_src *src, char *s, const char *pfx)/*{{{*/ newstring[q - copy_start] = 0; switch (last_copier) { case COPY_TO_NAME: - if (name) free(name); + free(name); name = newstring; #ifdef VERBOSE_TEST fprintf(stderr, " COPY_TO_NAME \"%s\"\n", name); #endif break; case COPY_TO_MINOR: - if (minor) free(minor); + free(minor); minor = newstring; #ifdef VERBOSE_TEST fprintf(stderr, " COPY_TO_MINOR \"%s\"\n", minor); #endif break; case COPY_TO_VALUE: - if (value) free(value); + free(value); value = newstring; #ifdef VERBOSE_TEST fprintf(stderr, " COPY_TO_VALUE \"%s\"\n", value); @@ -309,9 +317,9 @@ struct nvp *make_nvp(struct msg_src *src, char *s, const char *pfx)/*{{{*/ out: /* Not all productions consume these values */ - if (name) free(name); - if (value) free(value); - if (minor) free(minor); + free(name); + free(value); + free(minor); return result; } /*}}}*/ diff --git a/rfc822.c b/rfc822.c index 1949f20..6839828 100644 --- a/rfc822.c +++ b/rfc822.c @@ -863,7 +863,7 @@ static void do_multipart(struct msg_src *src, do { /* reject boundaries that aren't a whole line */ b1 = NULL; - for (bx = start_b1_search_from; bx < be - (boundary_len + 4); bx++) { + for (bx = start_b1_search_from; bx < be - (boundary_len + 2); bx++) { if (bx[0] == '-' && bx[1] == '-' && !strncmp(bx+2, boundary, boundary_len)) { b1 = bx; @@ -876,12 +876,12 @@ static void do_multipart(struct msg_src *src, return; } - looking_at_end_boundary = (b1[boundary_len+2] == '-' && + looking_at_end_boundary = (b1+boundary_len+3 < be) && (b1[boundary_len+2] == '-' && b1[boundary_len+3] == '-'); boundary_ok = 1; if ((b1 > input) && (*(b1-1) != '\n')) boundary_ok = 0; - if (!looking_at_end_boundary && !( + if (!looking_at_end_boundary && (b1 + boundary_len + 3 < be) && !( ((b1 + boundary_len + 2 < input + input_len) && (*(b1 + boundary_len + 2) == '\n')) || ((b1 + boundary_len + 3 < input + input_len) && (*(b1 + boundary_len + 2) == '\r') && (*(b1 + boundary_len + 3) == '\n')) )) diff --git a/search.c b/search.c index 5c5eb21..f8e70f0 100644 --- a/search.c +++ b/search.c @@ -1322,6 +1322,8 @@ static int do_search(struct read_db *db, char **args, char *output_path, int sho if (parsed->hdrs.subject) printf(" Subject: %s\n", parsed->hdrs.subject); if (parsed->hdrs.message_id) printf(" Message-ID: %s\n", parsed->hdrs.message_id); + if (parsed->hdrs.in_reply_to) + printf(" In-Reply-To:%s\n", parsed->hdrs.in_reply_to); thetm = gmtime(&parsed->hdrs.date); strftime(datebuf, sizeof(datebuf), "%a, %d %b %Y", thetm); printf(" Date: %s\n", datebuf);