debuggers.hg

view tools/libxl/libxlu_cfg_l.l @ 22855:1d1eec7e1fb4

xl: Perform minimal validation of virtual disk file while parsing config file

This patch performs some very basic validation on the virtual disk
file passed through the config file. This validation ensures that we
don't go too far with the initialization like spawn qemu and more
while there could be some potentially fundamental issues.

[ Patch fixed up to work with PHYSTYPE_EMPTY 22808:6ec61438713a -iwj ]

Signed-off-by: Kamala Narasimhan <kamala.narasimhan@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
author Kamala Narasimhan <kamala.narasimhan@gmail.com>
date Tue Jan 25 18:09:49 2011 +0000 (2011-01-25)
parents cb94dbe20f97
children
line source
1 /* -*- fundamental -*- */
3 %{
4 #include "libxlu_cfg_i.h"
6 #define ctx ((CfgParseContext*)yyextra)
7 #define YY_NO_INPUT
9 #define GOT(x) do{ \
10 yylloc->first_line= yylineno; \
11 return (x); \
12 }while(0)
14 /* Some versions of flex have a bug (Fedora bugzilla 612465) which causes
15 * it to fail to declare these functions, which it defines. So declare
16 * them ourselves. Hopefully we won't have to simultaneously support
17 * a flex version which declares these differently somehow. */
18 int xlu__cfg_yyget_column(yyscan_t yyscanner);
19 void xlu__cfg_yyset_column(int column_no, yyscan_t yyscanner);
21 %}
23 %option warn
24 %option nodefault
25 %option batch
26 %option 8bit
27 %option yylineno
28 %option noyywrap
29 %option bison-bridge
30 %option bison-locations
31 %option reentrant
32 %option prefix="xlu__cfg_yy"
33 %option nounput
35 %x lexerr
37 %%
39 [a-z][_0-9a-z]* {
40 yylval->string= xlu__cfgl_strdup(ctx,yytext);
41 GOT(IDENT);
42 }
43 [0-9][0-9a-fx]* {
44 yylval->string= xlu__cfgl_strdup(ctx,yytext);
45 GOT(NUMBER);
46 }
48 [ \t]
50 , { GOT(','); }
51 \[ { GOT('['); }
52 \] { GOT(']'); }
53 \= { GOT('='); }
54 \; { GOT(';'); }
56 \n|\#.*\n { yylloc->first_line= yylineno-1; return NEWLINE; }
58 \'([^\'\\\n]|\\.)*\' {
59 yylval->string= xlu__cfgl_dequote(ctx,yytext);
60 GOT(STRING);
61 }
62 \"([^\"\\\n]|\\.)*\" {
63 yylval->string= xlu__cfgl_dequote(ctx,yytext);
64 GOT(STRING);
65 }
67 [+-.():] {
68 ctx->likely_python= 1;
69 BEGIN(lexerr);
70 yymore();
71 }
73 . {
74 BEGIN(lexerr);
75 yymore();
76 }
78 <lexerr>[^ \t\n]*|[ \t] {
79 xlu__cfgl_lexicalerror(ctx,"lexical error");
80 BEGIN(0);
81 }
83 <lexerr>\n {
84 xlu__cfgl_lexicalerror(ctx,"lexical error");
85 BEGIN(0);
86 GOT(NEWLINE);
87 }