From 774c56094f3f3dcb1f25fe147c52604ad664bd5b Mon Sep 17 00:00:00 2001 From: eldritch horrors Date: Sat, 18 May 2024 17:48:27 +0200 Subject: [PATCH] libstore: fix old RemoteStore::addToStore serializer having the serializer write into `*conn` is not legal because we are in a sinkToSource that will be drained by the remote we're connected to. writing into `*conn` directly can break the framing protocol. it is unlikely this code was ever run: to protocol it caters to is from 2016(!) and thoroughly untested in-tree, and since it's been present since nix 2.17 and the 1.18 protocol broken here is nix 2.0 we might safely assume that daemons older than nix 2.1 are no longer used now see also #325 (though that wants <2.3 gone, this is sadly only <2.1) Change-Id: I9d674c18f6d802f61c5d85dfd9608587b73e70a5 --- src/libstore/remote-store.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libstore/remote-store.cc b/src/libstore/remote-store.cc index 1cdfdb925..22d87b027 100644 --- a/src/libstore/remote-store.cc +++ b/src/libstore/remote-store.cc @@ -509,7 +509,8 @@ void RemoteStore::addToStore(const ValidPathInfo & info, Source & source, sink << exportMagic << printStorePath(info.path); - WorkerProto::write(*this, *conn, info.references); + WorkerProto::WriteConn nested { .to = sink, .version = conn->daemonVersion }; + WorkerProto::write(*this, nested, info.references); sink << (info.deriver ? printStorePath(*info.deriver) : "") << 0 // == no legacy signature