From c84140e660d2b1952bd3ca39cb4b596b4172f49c Mon Sep 17 00:00:00 2001 From: Timo Pollmeier Date: Thu, 16 Sep 2021 09:31:52 +0200 Subject: [PATCH 1/2] Fix import of report results / errors without host The gmp_xml_handle_result function will now no longer try to remove newlines from the host if it is NULL. When importing reports, errors may not have any host assigned, which caused a segmentation fault without the added check (AP-1641). --- src/gmp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/gmp.c b/src/gmp.c index c1da7f7d8..663a650db 100644 --- a/src/gmp.c +++ b/src/gmp.c @@ -18169,8 +18169,9 @@ gmp_xml_handle_result () // https://www.freebsd.org/cgi/man.cgi?query=strcspn&sektion=3 // strcspn returns the number of chars spanned so it should be safe // without double checking. - create_report_data - ->result_host[strcspn (create_report_data->result_host, "\n")] = 0; + if (create_report_data->result_host) + create_report_data + ->result_host[strcspn (create_report_data->result_host, "\n")] = 0; result->host = create_report_data->result_host; result->hostname = create_report_data->result_hostname; result->nvt_oid = create_report_data->result_nvt_oid; From 584b55255c8c10aa994d1bebb9feaed332b9ae48 Mon Sep 17 00:00:00 2001 From: Timo Pollmeier Date: Thu, 16 Sep 2021 09:41:38 +0200 Subject: [PATCH 2/2] Add report import fix to CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b0861a4af..e4c63c448 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Removed ### Fixed - Fix resume task. [#1679](https://github.com/greenbone/gvmd/pull/1679) +- Fix import of report results / errors without host [#1687](https://github.com/greenbone/gvmd/pull/1687) [Unreleased]: https://github.com/greenbone/gvmd/compare/v21.4.3...HEAD