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

archive/tar: slice bounds out of range (4) #10967

Closed
dvyukov opened this issue May 27, 2015 · 4 comments
Closed

archive/tar: slice bounds out of range (4) #10967

dvyukov opened this issue May 27, 2015 · 4 comments

Comments

@dvyukov
Copy link
Member

dvyukov commented May 27, 2015

The following program crashes with a panic:

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\xf410100t\x13\x13\x83s|\x83ss" +
    "\x000\x13s|\x83ss\xf4xS\x13s\xf410100t" +
    "\x13\x13\x83s|\x00ss\xf40\x13s|\x83ss0qS0" +
    "\xd4t0\x1300q000\x00\x00\x00\x1001\x80\x00\x100" +
    "11\x13s\xf410\x00\xf40t\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\x80\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\x00\x00\x00\x00\x00\x00\x004\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)
    }
}
panic: runtime error: slice bounds out of range

goroutine 1 [running]:
archive/tar.(*regFileReader).Read(0xc20800e460, 0xc208074000, 0x2000, 0x2000, 0x4, 0x0, 0x0)
    src/archive/tar/reader.go:748 +0x170
archive/tar.(*sparseFileReader).Read(0xc2080143c0, 0xc208074000, 0x2000, 0x2000, 0x4, 0x0, 0x0)
    src/archive/tar/reader.go:803 +0x1c3
archive/tar.(*Reader).Read(0xc208070000, 0xc208074000, 0x2000, 0x2000, 0x4, 0x0, 0x0)
    src/archive/tar/reader.go:735 +0x9d
io/ioutil.devNull.ReadFrom(0x0, 0x7fb1646c1298, 0xc208070000, 0x4, 0x0, 0x0)
    src/io/ioutil/ioutil.go:151 +0xa1
io/ioutil.(*devNull).ReadFrom(0xc20800a4a0, 0x7fb1646c1298, 0xc208070000, 0xc208041e40, 0x0, 0x0)
    <autogenerated>:9 +0xb4
io.copyBuffer(0x7fb1646c11c0, 0xc20800a4a0, 0x7fb1646c1298, 0xc208070000, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
    src/io/io.go:375 +0x183
io.Copy(0x7fb1646c11c0, 0xc20800a4a0, 0x7fb1646c1298, 0xc208070000, 0x200, 0x0, 0x0)
    src/io/io.go:351 +0x6b
main.main()
    tar.go:43 +0x1df

on commit 8017ace

@dvyukov dvyukov added this to the Go1.5 milestone May 27, 2015
@dsymonds dsymonds modified the milestones: Go1.5Maybe, Go1.5 May 27, 2015
@dsymonds dsymonds removed their assignment May 27, 2015
@kf6nux
Copy link

kf6nux commented May 29, 2015

Are your third (#10966) and fourth (#10967) issue reports not resolved by the patch that closed your first (#10959) and second (#10960) issue reports?

@dvyukov
Copy link
Member Author

dvyukov commented May 29, 2015

At least in one of them top stack frame was different, so I guess there is another bug.

@osocurioso
Copy link
Contributor

Cannot reproduce this since 02f4084.

@dvyukov
Copy link
Member Author

dvyukov commented May 30, 2015

Yes, seems to be fixed

@dvyukov dvyukov closed this as completed May 30, 2015
@mikioh mikioh modified the milestones: Go1.5, Go1.5Maybe Jun 2, 2015
@golang golang locked and limited conversation to collaborators Jun 25, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants