Giter Club home page Giter Club logo

Comments (3)

kalamay avatar kalamay commented on May 26, 2024

Hi @Mrs4s, thanks for sending this in. I'll take a look!

from asm.

wdvxdr1123 avatar wdvxdr1123 commented on May 26, 2024

asm/base64/base64_amd64.go

Lines 145 to 147 in 86603cd

func (enc *Encoding) DecodeString(s string) ([]byte, error) {
src := *(*[]byte)(unsafe.Pointer(&s))
dst := make([]byte, enc.base.DecodedLen(len(s)))

Hi @kalamay , I think this unsafe usage is not correct, because string header has only 2 field but slice header has 3 field.
I have a program using this lib and it panics in std library encoding/json randomly on a computer without avx2 feature.
with panic info:

runtime error: slice bounds out of range [:8] with capacity 4

panic({0xc5d660, 0xc0003ce0a8})
        runtime/panic.go:1038 +0x215
encoding/base64.(*Encoding).Decode(0xc0000ca580, {0xc000418000, 0x5fc7, 0x5fc7}, {0xc0008120d1, 0x7fb4, 0xc000058c00})
        encoding/base64/base64.go:483 +0x605
github.com/segmentio/asm/base64.(*Encoding).Decode(0x41259a, {0xc000418000, 0x6a34044efc013184, 0x636f727070410f01}, {0xc0008120d1, 0xb2e589b8e41701b1, 0x0})
        github.com/segmentio/[email protected]/base64/base64_amd64.go:138 +0x14d
github.com/segmentio/asm/base64.(*Encoding).DecodeString(0xc00007e370, {0xc0008120d1, 0x7fb4})
        github.com/segmentio/[email protected]/base64/base64_amd64.go:148 +0xb7

I am convinced that it is caused by the unsafe convertion which produced incorrect slice capacity.

from asm.

kalamay avatar kalamay commented on May 26, 2024

Yep, that was this issue. I've included a few updates to some internal table handling as well, but this issue should be resolved now. I appreciate you reporting this issue to us.

from asm.

Related Issues (14)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.