On Sat, Apr 28, 2007 at 11:31:35AM -0400, Stephen Isard wrote:
> Hello,
>
> On a Fedora Core 5 machine with
>
> $ gcc --version
> gcc (GCC) 4.1.1 20060525 (Red Hat 4.1.1-1)
>
> mairix 2.0 compiles and runs with no problems. On a different FC5 machine
> with
>
> $ gcc --version
> gcc (GCC) 4.1.1 20070105 (Red Hat 4.1.1-51)
>
> I get a binary that segfaults while trying to index several largish (~1000
> messages) mbox files.
Does the attached patch fix it?
There's more work to be done before a new release, though.
>From 33a9a840216bf336c14df429f6e36acf939de9e1 Mon Sep 17 00:00:00 2001
From: Richard P. Curnow <[EMAIL PROTECTED]>
Date: Sat, 21 Apr 2007 23:52:03 +0100
Subject: [PATCH] Ensure name/value parser bails out gracefully.
Previously, if the DFA got confused a segfault could arise.
---
nvp.c | 33 +++++++++++++++++++++++++--------
1 files changed, 25 insertions(+), 8 deletions(-)
diff --git a/nvp.c b/nvp.c
index fb63f7b..3aa90d4 100644
--- a/nvp.c
+++ b/nvp.c
@@ -85,6 +85,26 @@ static void append_namevalue(struct nvp *nvp, char *name,
char *value)/*{{{*/
append(nvp, ne);
}
/*}}}*/
+static void release_nvp(struct nvp *nvp)/*{{{*/
+{
+ struct nvp_entry *e, *ne;
+ for (e=nvp->first; e; e=ne) {
+ ne = e->next;
+ switch (e->type) {
+ case NVP_NAME:
+ free(e->lhs);
+ break;
+ case NVP_MAJORMINOR:
+ case NVP_NAMEVALUE:
+ free(e->lhs);
+ free(e->rhs);
+ break;
+ }
+ free(e);
+ }
+ free(nvp);
+}
+/*}}}*/
struct nvp *make_nvp(char *s)/*{{{*/
{
int current_state;
@@ -116,14 +136,11 @@ struct nvp *make_nvp(char *s)/*{{{*/
tok = nvp_EOS;
}
current_state = nvp_next_state(current_state, tok);
-#if 0
- printf("char %02x '%c' meta=%2d state'=%2d ",
- *q,
- (*q >= 32 && *q <= 126) ? *q : '.',
- tok,
- current_state
- );
-#endif
+
+ if (current_state < 0) {
+ release_nvp(result);
+ return NULL;
+ }
switch (nvp_copier[current_state]) {
case COPY_TO_NAME:
--
1.5.0.3
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Mairix-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mairix-users