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

stream.operation.readUntil: generates broken output when str is changed while reading #960

Closed
tomykaira opened this issue Jan 18, 2015 · 1 comment

Comments

@tomykaira
Copy link

When used with GzipInputStream and a specific file, content of str set by peek() opeartion.d#L152 is implicitly changed by read() call in skip.
This results in broken output from dst.put.

Simple solution is to replace stream.peek() with stream.peek().dup, which works correctly, but the performance effect may be too much.

Here are test code, but I cannot provide the problematic file, because it contains confidential data.
It is log data with 5 lines and each line contains 100-5000 ascii characters.
I tried to make a similar file, but couldn't.
So sorry about inconvenience.

unittest {
    import vibe.core.file;
    import vibe.stream.zlib;
    auto fs = openFile("problematic.txt.gz");
    scope(exit) fs.close();

    string byline = "";
    auto gis = new GzipInputStream(fs);
    while (!gis.empty()) {
        byline ~= cast(string) readLine(gis, size_t.max, "\x0a") ~ "\x0a";
    }
    fs.seek(0);
    auto gis2 = new GzipInputStream(fs);
    string byall = cast(string) readAll(gis2);
    assert(byline == byall);
}
@s-ludwig
Copy link
Member

Fixed by 78140aa

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants