Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ZipFile hangs when encountering named pipe #85097

Closed
tmds opened this issue Apr 20, 2023 · 3 comments · Fixed by #85301
Closed

ZipFile hangs when encountering named pipe #85097

tmds opened this issue Apr 20, 2023 · 3 comments · Fixed by #85301

Comments

@tmds
Copy link
Member

tmds commented Apr 20, 2023

The following program hangs:

using System.ComponentModel;
using System.IO.Compression;
using System.Runtime.InteropServices;

var dir = Directory.CreateDirectory(Path.Combine(Path.GetTempPath(), Path.GetRandomFileName())).FullName;
int res = MkFifo(Path.Combine(dir, "fifo"), 0x1ff);
if (res != 0)
{
    throw new Win32Exception();
}

ZipFile.CreateFromDirectory(dir, Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()));

[DllImport("libSystem.Native", EntryPoint = "SystemNative_MkFifo", SetLastError = true)]
static extern int MkFifo(string pathName, uint mode);

ZipFile handles the fifo as a regular file. The open call doesn't return (because there is no peer that has it opened for writing, and the fifo isn't opened as non-blocking).

Instead of trying to open the fifo, we should either skip it, or throw an exception for encountering an unsupported file type.

@ghost ghost added the untriaged New issue has not been triaged by the area owner label Apr 20, 2023
@ghost
Copy link

ghost commented Apr 20, 2023

Tagging subscribers to this area: @dotnet/area-system-io
See info in area-owners.md if you want to be subscribed.

Issue Details

The following program hangs:

using System.ComponentModel;
using System.IO.Compression;
using System.Runtime.InteropServices;

var dir = Directory.CreateDirectory(Path.Combine(Path.GetTempPath(), Path.GetRandomFileName())).FullName;
int res = MkFifo(Path.Combine(dir, "fifo"), 0x1ff);
if (res != 0)
{
    throw new Win32Exception();
}

ZipFile.CreateFromDirectory(dir, Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()));

[DllImport("libSystem.Native", EntryPoint = "SystemNative_MkFifo", SetLastError = true)]
static extern int MkFifo(string pathName, uint mode);

ZipFile handles the fifo as a regular file. The open call doesn't return (because there is no peer that has it opened for writing, and the fifo isn't opened as non-blocking).

Instead of trying to open the fifo, we should either skip it, or throw an exception for encountering an unsupported file type.

Author: tmds
Assignees: -
Labels:

area-System.IO, untriaged

Milestone: -

@ghost
Copy link

ghost commented Apr 21, 2023

Tagging subscribers to this area: @dotnet/area-system-io-compression
See info in area-owners.md if you want to be subscribed.

Issue Details

The following program hangs:

using System.ComponentModel;
using System.IO.Compression;
using System.Runtime.InteropServices;

var dir = Directory.CreateDirectory(Path.Combine(Path.GetTempPath(), Path.GetRandomFileName())).FullName;
int res = MkFifo(Path.Combine(dir, "fifo"), 0x1ff);
if (res != 0)
{
    throw new Win32Exception();
}

ZipFile.CreateFromDirectory(dir, Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()));

[DllImport("libSystem.Native", EntryPoint = "SystemNative_MkFifo", SetLastError = true)]
static extern int MkFifo(string pathName, uint mode);

ZipFile handles the fifo as a regular file. The open call doesn't return (because there is no peer that has it opened for writing, and the fifo isn't opened as non-blocking).

Instead of trying to open the fifo, we should either skip it, or throw an exception for encountering an unsupported file type.

Author: tmds
Assignees: -
Labels:

area-System.IO, area-System.IO.Compression, untriaged

Milestone: -

@tmds tmds removed area-System.IO untriaged New issue has not been triaged by the area owner labels Apr 21, 2023
@tmds
Copy link
Member Author

tmds commented Apr 21, 2023

we should either skip it, or throw an exception for encountering an unsupported file type.

The tar writer throws for unsupported types:

_ => throw new IOException(SR.Format(SR.TarUnsupportedFile, fullPath)),

@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Apr 25, 2023
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label May 18, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Jun 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant