From b604c97b33de1785a10b2df2b3eaa48f2bee0719 Mon Sep 17 00:00:00 2001 From: Archie Date: Tue, 14 Jun 2022 14:17:00 +0100 Subject: Add check for BLIF with no model name --- frontends/blif/blifparse.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'frontends/blif') diff --git a/frontends/blif/blifparse.cc b/frontends/blif/blifparse.cc index 19844bda6..73d1f0ea7 100644 --- a/frontends/blif/blifparse.cc +++ b/frontends/blif/blifparse.cc @@ -166,7 +166,10 @@ void parse_blif(RTLIL::Design *design, std::istream &f, IdString dff_name, bool goto error; module = new RTLIL::Module; lastcell = nullptr; - module->name = RTLIL::escape_id(strtok(NULL, " \t\r\n")); + char *name = strtok(NULL, " \t\r\n"); + if (name == nullptr) + goto error; + module->name = RTLIL::escape_id(name); obj_attributes = &module->attributes; obj_parameters = nullptr; if (design->module(module->name)) -- cgit v1.2.3 From 15a0697c70e14d6277e26f6fa21898be5a8f6ff8 Mon Sep 17 00:00:00 2001 From: Archie Date: Sun, 21 Aug 2022 23:18:20 -0500 Subject: Adding check for BLIF names command input plane size. --- frontends/blif/blifparse.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'frontends/blif') diff --git a/frontends/blif/blifparse.cc b/frontends/blif/blifparse.cc index 73d1f0ea7..52742660e 100644 --- a/frontends/blif/blifparse.cc +++ b/frontends/blif/blifparse.cc @@ -21,6 +21,8 @@ YOSYS_NAMESPACE_BEGIN +const int lut_input_plane_limit = 12; + static bool read_next_line(char *&buffer, size_t &buffer_size, int &line_count, std::istream &f) { string strbuf; @@ -513,6 +515,11 @@ void parse_blif(RTLIL::Design *design, std::istream &f, IdString dff_name, bool sopmode = -1; lastcell = sopcell; } + else if (input_sig.size() > lut_input_plane_limit) + { + err_reason = stringf("names' input plane must have fewer than 13 signals."); + goto error_with_reason; + } else { RTLIL::Cell *cell = module->addCell(NEW_ID, ID($lut)); @@ -576,7 +583,7 @@ void parse_blif(RTLIL::Design *design, std::istream &f, IdString dff_name, bool if (lutptr) { - if (input_len > 12) + if (input_len > lut_input_plane_limit) goto error; for (int i = 0; i < (1 << input_len); i++) { -- cgit v1.2.3 From d29606532a15ae8e0c8d6c3591ccb36652d7339b Mon Sep 17 00:00:00 2001 From: Archie Date: Sun, 2 Oct 2022 21:59:46 +0200 Subject: Changing error reason string to be based on lut input plane limit constant. --- frontends/blif/blifparse.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'frontends/blif') diff --git a/frontends/blif/blifparse.cc b/frontends/blif/blifparse.cc index 52742660e..fe4c9078a 100644 --- a/frontends/blif/blifparse.cc +++ b/frontends/blif/blifparse.cc @@ -517,7 +517,7 @@ void parse_blif(RTLIL::Design *design, std::istream &f, IdString dff_name, bool } else if (input_sig.size() > lut_input_plane_limit) { - err_reason = stringf("names' input plane must have fewer than 13 signals."); + err_reason = stringf("names' input plane must have fewer than %d signals.", lut_input_plane_limit + 1); goto error_with_reason; } else -- cgit v1.2.3