• Jason A. Donenfeld's avatar
    internal/syscall/windows/registry: allow for non-null terminated strings · 3c25e5ec
    Jason A. Donenfeld authored
    According to MSDN, "If the data has the REG_SZ, REG_MULTI_SZ or
    REG_EXPAND_SZ type, this size includes any terminating null character or
    characters unless the data was stored without them. [...] If the data
    has the REG_SZ, REG_MULTI_SZ or REG_EXPAND_SZ type, the string may not
    have been stored with the proper terminating null characters. Therefore,
    even if the function returns ERROR_SUCCESS, the application should
    ensure that the string is properly terminated before using it;
    otherwise, it may overwrite a buffer."
    
    It's therefore dangerous to pass it off unbounded as we do, and in fact
    this led to crashes on real systems.
    
    Change-Id: I6d786211814656f036b87fd78631466634cd764a
    Reviewed-on: https://go-review.googlesource.com/c/go/+/202937
    Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    Reviewed-by: default avatarAlex Brainman <alex.brainman@gmail.com>
    3c25e5ec
value.go 11.4 KB