Switching a multi-volume archive file with another active filter, e.g.
decompression, can lead to memory corruption due to modifying the wrong
private data (self->data).
Use highest upstream filter to replace the correct private data.
Resolves GHSA-qf8j-cq3h-8m2m.
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
static int
client_switch_proxy(struct archive_read_filter *self, unsigned int iindex)
{
- struct archive_read *a = self->archive;
+ struct archive_read *a;
int r1 = ARCHIVE_OK, r2 = ARCHIVE_OK;
void *data2;
+ while (self->upstream != NULL)
+ self = self->upstream;
+ a = self->archive;
+
/* Don't do anything if already in the specified data node */
if (a->client.cursor == iindex)
return (ARCHIVE_OK);