mirror of https://gitlab.com/qemu-project/dtc.git
dtc: Fix zero-length input segfault
This patch fixes a segmentation fault caused by dereferencing a NULL pointer (pos->file aka yylloc.file) in srcpos_string when the input length is 0 (fe 'dtc </dev/null'.) Reason: yylloc.file is initialized with 0 and the tokenizer, which updates yylloc.file via srcpos_update doesn't get a chance to run on zero-length input. Signed-off-by: Horst Kronstorfer <hkronsto@frequentis.com>
This commit is contained in:
parent
e280442e08
commit
a6e6c60e3a
|
@ -23,6 +23,7 @@
|
||||||
|
|
||||||
extern FILE *yyin;
|
extern FILE *yyin;
|
||||||
extern int yyparse(void);
|
extern int yyparse(void);
|
||||||
|
extern YYLTYPE yylloc;
|
||||||
|
|
||||||
struct boot_info *the_boot_info;
|
struct boot_info *the_boot_info;
|
||||||
int treesource_error;
|
int treesource_error;
|
||||||
|
@ -34,6 +35,7 @@ struct boot_info *dt_from_source(const char *fname)
|
||||||
|
|
||||||
srcfile_push(fname);
|
srcfile_push(fname);
|
||||||
yyin = current_srcfile->f;
|
yyin = current_srcfile->f;
|
||||||
|
yylloc.file = current_srcfile;
|
||||||
|
|
||||||
if (yyparse() != 0)
|
if (yyparse() != 0)
|
||||||
die("Unable to parse input tree\n");
|
die("Unable to parse input tree\n");
|
||||||
|
|
Loading…
Reference in New Issue