[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[augeas-devel] augeas: master - * src/pathx.c: it is an error if we don't consume the whole expression



Gitweb:        http://git.fedorahosted.org/git/augeas.git?p=augeas.git;a=commitdiff;h=9bcd7b66aa6781d69d917166293fc80cfdab4066
Commit:        9bcd7b66aa6781d69d917166293fc80cfdab4066
Parent:        39783f31002f1f6d8ccb44f3841e9ceb3efcf43c
Author:        David Lutterkort <lutter redhat com>
AuthorDate:    Mon Mar 2 11:11:50 2009 -0800
Committer:     David Lutterkort <lutter redhat com>
CommitterDate: Mon Mar 2 11:11:50 2009 -0800

* src/pathx.c: it is an error if we don't consume the whole expression

---
 src/internal.h |    3 ++-
 src/pathx.c    |    7 ++++++-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/internal.h b/src/internal.h
index faa407f..1b020c5 100644
--- a/src/internal.h
+++ b/src/internal.h
@@ -369,7 +369,8 @@ typedef enum {
     PATHX_EPAREN,
     PATHX_ESLASH,
     PATHX_EINTERNAL,
-    PATHX_ETYPE
+    PATHX_ETYPE,
+    PATHX_EEND
 } pathx_errcode_t;
 
 struct pathx;
diff --git a/src/pathx.c b/src/pathx.c
index 25446e5..5da5caf 100644
--- a/src/pathx.c
+++ b/src/pathx.c
@@ -39,7 +39,8 @@ static const char *const errcodes[] = {
     "unmatched '('",
     "expected a '/'",
     "internal error",   /* PATHX_EINTERNAL */
-    "type error"        /* PATHX_ETYPE */
+    "type error",       /* PATHX_ETYPE */
+    "garbage at end of path expression" /* PATHX_EEND */
 };
 
 /*
@@ -1583,6 +1584,10 @@ int pathx_parse(const struct tree *tree, const char *txt,
     parse_expr(state);
     if (HAS_ERROR(state))
         goto done;
+    if (state->pos != state->txt + strlen(state->txt)) {
+        STATE_ERROR(state, PATHX_EEND);
+        goto done;
+    }
 
     if (state->exprs_used != 1) {
         STATE_ERROR(state, PATHX_EINTERNAL);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]