这是indexloc提供的服务,不要输入任何密码
Skip to content

envv segfault with particular output size #1

@bukzor

Description

@bukzor

I know this isn't really your code, but you seem to be the only one working on it.

This error is sensitive to the length of input. Whenever the length of variable plus value, plus added value is 181, I get this error. You can increase the variable name length, as long as you reduce one of the other two strings by the same amount, and so on.

The below examples are contrived, but I found this because a production system encountered this error, causing environment values to not be properly updated.

Demo:

export x=01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678

cat <<EOF | ./envv
    add x 0
EOF

x=01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678:0; export x
Segmentation fault

Also:

export x=012345678901234567890123456789012345678901234567890123456789012345678901234567890

cat <<EOF | ./envv
    add x 012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678
EOF

x=012345678901234567890123456789012345678901234567890123456789012345678901234567890:012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678; export x
Segmentation fault

And:

export x0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789=0123456789012345678901234567890123456789012345678901234567890123456789012345678

cat <<EOF | ./envv
    add x012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 0
EOF

x012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789=01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678:0; export x012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
Segmentation fault

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions