* [PATCH] dtc: Fix zero-length input segfault
@ 2012-02-08 7:22 Horst Kronstorfer
0 siblings, 0 replies; 3+ messages in thread
From: Horst Kronstorfer @ 2012-02-08 7:22 UTC (permalink / raw)
To: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ; +Cc: Horst Kronstorfer
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-USXAA5bZaHGDvotElmWtJA@public.gmane.org>
---
treesource.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/treesource.c b/treesource.c
index c09aafa..33eeba5 100644
--- a/treesource.c
+++ b/treesource.c
@@ -23,6 +23,7 @@
extern FILE *yyin;
extern int yyparse(void);
+extern YYLTYPE yylloc;
struct boot_info *the_boot_info;
int treesource_error;
@@ -34,6 +35,7 @@ struct boot_info *dt_from_source(const char *fname)
srcfile_push(fname);
yyin = current_srcfile->f;
+ yylloc.file = current_srcfile;
if (yyparse() != 0)
die("Unable to parse input tree\n");
--
1.7.7.6
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] dtc: Fix zero-length input segfault
[not found] ` <1328605373-14063-1-git-send-email-hkronsto-USXAA5bZaHGDvotElmWtJA@public.gmane.org>
@ 2012-02-17 15:14 ` Jon Loeliger
0 siblings, 0 replies; 3+ messages in thread
From: Jon Loeliger @ 2012-02-17 15:14 UTC (permalink / raw)
To: Horst Kronstorfer; +Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ
> 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-USXAA5bZaHGDvotElmWtJA@public.gmane.org>
Applied.
Thanks,
jdl
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] dtc: Fix zero-length input segfault
@ 2012-02-07 9:02 Horst Kronstorfer
[not found] ` <1328605373-14063-1-git-send-email-hkronsto-USXAA5bZaHGDvotElmWtJA@public.gmane.org>
0 siblings, 1 reply; 3+ messages in thread
From: Horst Kronstorfer @ 2012-02-07 9:02 UTC (permalink / raw)
To: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ; +Cc: Horst Kronstorfer
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-USXAA5bZaHGDvotElmWtJA@public.gmane.org>
---
treesource.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/treesource.c b/treesource.c
index c09aafa..33eeba5 100644
--- a/treesource.c
+++ b/treesource.c
@@ -23,6 +23,7 @@
extern FILE *yyin;
extern int yyparse(void);
+extern YYLTYPE yylloc;
struct boot_info *the_boot_info;
int treesource_error;
@@ -34,6 +35,7 @@ struct boot_info *dt_from_source(const char *fname)
srcfile_push(fname);
yyin = current_srcfile->f;
+ yylloc.file = current_srcfile;
if (yyparse() != 0)
die("Unable to parse input tree\n");
--
1.7.7.6
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-02-17 15:14 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-08 7:22 [PATCH] dtc: Fix zero-length input segfault Horst Kronstorfer
-- strict thread matches above, loose matches on Subject: below --
2012-02-07 9:02 Horst Kronstorfer
[not found] ` <1328605373-14063-1-git-send-email-hkronsto-USXAA5bZaHGDvotElmWtJA@public.gmane.org>
2012-02-17 15:14 ` Jon Loeliger
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.