Skip to content

archive/tar: deadly hang #10968

Closed
Closed
@dvyukov

Description

The following program hangs:

package main

import (
    "archive/tar"
    "bytes"
    "io"
    "io/ioutil"
)

func main() {
    data := []byte("\x13\x0300\x13\x03-821950296t\x13\x13\x83" +
    "s|\x83s\x1300qw\xe1f\x00\x03000\x00\x00\x00\x10" +
    "011\x13s\xf4\x000100t\x13\x13\x83s|\x83ss" +
    "\x000\x13s|\x83ss\xf4xS\x13s\xf410100t" +
    "\x13\x13\x83s|\x00ss\xf40\x13s|\x83ss0qS0" +
    "\xd4t0\x1300q0\xf40\x00\x00\x00\x1001\x80\x00\x100" +
    "11\x13s\xf410\x0000t\x1300q\xd4\xe1f\xbb\x03" +
    "\x00\x00\x00\xff\x80\x80\x80\x00\x80\x00\x00\x00\x00\x00j.S\x13\xff\xff" +
    "\xff\x80100txS00t0\x1300qw010" +
    "100t\x13\x13\x83s|\x83ss\xf4xS00t0\x13" +
    "00qw\xe1f\xbb\x03000\x00\x00\x00\x10011\x13s" +
    "\xf410100t\x13\x13\x83s|\x83ss\xf40\x13s|" +
    "\x83s\xf4\xf4xS\x13s\xf410\x0000t\x13\x13\x83s|" +
    "\x00ss00\x13s|\x83sssx100t0\x130" +
    "0q00\x00\x00\x00\x00\x1001s\xf4100100t" +
    "\x13\x00\x00\x00 \xe1f\xbb\x0304\x00\x00\x00\x10011\x13\xff" +
    "\xff\xff\x80100txS00t0\x1300qw\xe1f" +
    "\xbb\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" +
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" +
    "\x00\x00\x00\x00\x00\x00\x80\x00\x00\x00\x00\x0014\x00\x00\x00\x00\xbb\x00" +
    "\x00\x00\x00\x00\x00\x00\x00\x001\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" +
    "\x00\x00\x00\x00\x00\x00\x001\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" +
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" +
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" +
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" +
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00")
    t := tar.NewReader(bytes.NewReader(data))
    for {
        _, err := t.Next()
        if err != nil {
            return
        }
        io.Copy(ioutil.Discard, t)
    }
}

A profile says that the program loops in archive/tar.(*sparseFileReader).readHole.
on commit 8017ace

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions