libxl: correctly initialise yylineno
PATCH 1/1 libxl: correctly initialise yylineno
Sometimes xl would read an uninitialised variable when printing error messages, resulting in things like this:
/etc/xen/thing.cfg:1030057088: config parsing error near `"ws08r2-x64-2': lexical error
This is because yylineno is a variable inside the scanner created by yylex_init, but it is not initialised by yylex_init. (Debian bug #616099.)
On the way I discovered a lot of complication to do with the calling convention between bison and flex in reentrant parsers/scanners which use locations (Debian bug #616100) but as the above change makes the current code in xen-unstable work I don't propose to do anything else about that now in our tree.
--- tools/libxl/libxlu_cfg.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
tools/libxl/libxlu_cfg.c +3 -0
@@ -43,6 +43,9 @@ static void ctx_dispose(CfgParseContext *ctx) {static void parse (CfgParseContext *ctx) {/* On return, ctx.err will be updated with the error status. */ int r; + +xlu__cfg_yyset_lineno (1 , ctx->scanner); + r=xlu__cfg_yyparse (ctx);if (r)assert (ctx->err);
Signature · 1 line
1.5.6.5
Quoted 8 lines · Ian Jackson
Sometimes xl would read an uninitialised variable when printing error messages, resulting in things like this:
/etc/xen/thing.cfg:1030057088: config parsing error near `"ws08r2-x64-2': lexical errorThis is because yylineno is a variable inside the scanner created by
yylex_init, but it is not initialised byyylex_init. (Debian bug #616099.)
Quoted 7 lines
On the way I discovered a lot of complication to do with the calling convention between bison and flex in reentrant parsers/scanners which use locations (Debian bug #616100) but as the above change makes the current code in xen-unstable work I don't propose to do anything else about that now in our tree.
Signed-off-by Ian Jackson <[email protected]>
This fixes the issue I was having:
# xl cr -d /root/x
Parsing config file /root/x
/root/x:24: config parsing error near `"ws08r2-x64-2': lexical error
Failed to parse config file: Invalid argumentWhere line 24 does indeed contain an error.
Tested/Acked-by: Ian Campbell <[email protected]>
Quoted 18 lines
--- tools/libxl/libxlu_cfg.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)tools/libxl/libxlu_cfg.c +3
-0@@ -43,6 +43,9 @@ static void ctx_dispose(CfgParseContext *ctx) {static void parse (CfgParseContext *ctx) {/* On return, ctx.err will be updated with the error status. */ int r; + +xlu__cfg_yyset_lineno (1 , ctx->scanner); + r=xlu__cfg_yyparse (ctx);if (r)assert (ctx->err);
Ian Campbell writes ("Re: [Xen-devel] [PATCH] libxl: correctly initialise yylineno"):
Quoted 3 lines · Ian Jackson
Quoted 2 lines
Sometimes xl would read an uninitialised variable when printing error messages, resulting in things like this:
...>
Quoted 1 line
This fixes the issue I was having:
Thanks for the report and review; committed.
Ian.