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

process: fix reading zero-length env vars on win32 #18463

Closed
wants to merge 1 commit into from

Commits on Jan 30, 2018

  1. process: fix reading zero-length env vars on win32

    Up until now, Node did not clear the current error code
    attempting to read environment variables on Windows.
    Since checking the error code is the way we distinguish between
    missing and zero-length environment variables, this could lead to a
    false positive when the error code was still tainted.
    
    In the simplest case, accessing a missing variable and then a
    zero-length one would lead Node to believe that both calls yielded
    an error.
    
    Before:
    
        > process.env.I=''; process.env.Q; process.env.I
        undefined
        > process.env.I=''; /*process.env.Q;*/ process.env.I
        ''
    
    After:
    
        > process.env.I=''; process.env.Q; process.env.I
        ''
        > process.env.I=''; /*process.env.Q;*/ process.env.I
        ''
    
    This only affects Node 8 and above, since before
    1aa595e we always constructed a
    `v8::String::Value` instance for passing the lookup key to the OS,
    which in in turn always made a heap allocation and therefore
    reset the error code.
    addaleax committed Jan 30, 2018
    Configuration menu
    Copy the full SHA
    52d4e3b View commit details
    Browse the repository at this point in the history