From c581df72194f30e7b2c94a290e2e07e0309b3968 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Tue, 7 Feb 2006 00:22:25 +0000 Subject: [PATCH] Fix dfa_match_first to avoid match past nul byte --- data1/d1_absyn.c | 6 +++--- recctrl/recgrs.c | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/data1/d1_absyn.c b/data1/d1_absyn.c index 43291b3..8dc0fe2 100644 --- a/data1/d1_absyn.c +++ b/data1/d1_absyn.c @@ -1,4 +1,4 @@ -/* $Id: d1_absyn.c,v 1.9.2.6 2006-02-06 23:16:03 adam Exp $ +/* $Id: d1_absyn.c,v 1.9.2.7 2006-02-07 00:22:25 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002 Index Data Aps @@ -345,9 +345,9 @@ static const char * mk_xpath_regexp (data1_handle dh, const char *expr) *res_p = '\0'; if (stack[e-1][0] == '@') /* path/@attr spec (leaf is attribute) */ - sprintf(res_p, "/"); + strcpy(res_p, "/"); else - sprintf(res_p, "[^@]*/"); /* path .. (index all cdata below it) */ + strcpy(res_p, "[^@]*/"); /* path .. (index all cdata below it) */ res_p = res_p + strlen(res_p); while (--e >= 0) { sprintf(res_p, "%s/", stack[e]); diff --git a/recctrl/recgrs.c b/recctrl/recgrs.c index 37c8132..cb842a2 100644 --- a/recctrl/recgrs.c +++ b/recctrl/recgrs.c @@ -1,4 +1,4 @@ -/* $Id: recgrs.c,v 1.86.2.8 2006-02-06 23:16:03 adam Exp $ +/* $Id: recgrs.c,v 1.86.2.9 2006-02-07 00:22:25 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003 Index Data Aps @@ -406,6 +406,8 @@ static int dfa_match_first(struct DFA_state **dfaar, const char *text) if (s->rule_no) return 1; /* next char */ + if (!c) + return 0; c = *p++; for (t = s->trans, i = s->tran_no; --i >= 0; t++) if (c >= t->ch[0] && c <= t->ch[1]) -- 1.7.10.4