From 8b7c6d8d0d5cdf99f4028b4f8c49efb5a9e5d369 Mon Sep 17 00:00:00 2001 From: Marius Goetze Date: Thu, 26 Sep 2024 11:03:36 +0200 Subject: [PATCH] fix: return valid byte slice on csaf channel Send a newly created byte slice with the csaf document content on the channel. Previously the sent byte slice was gained from the method `Buffer.Bytes()`. However this "slice is valid for use only until the next buffer modification" and therefore modified with the next buffer modification.. --- cmd/csaf_downloader/downloader.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cmd/csaf_downloader/downloader.go b/cmd/csaf_downloader/downloader.go index e7639a51..a50e562d 100644 --- a/cmd/csaf_downloader/downloader.go +++ b/cmd/csaf_downloader/downloader.go @@ -24,6 +24,7 @@ import ( "os" "path" "path/filepath" + "slices" "strconv" "strings" "sync" @@ -678,7 +679,8 @@ nextAdvisory: } if d.cfg.ForwardChannel { - d.Csafs <- data.Bytes() + // the bytes slice is modified by the next buffer modification, so we need to copy it + d.Csafs <- slices.Clone(data.Bytes()) } if d.cfg.NoStore {