build(deps): bump github.com/Microsoft/hcsshim from 0.8.20 to 0.9.6
Bumps [github.com/Microsoft/hcsshim](https://github.com/Microsoft/hcsshim) from 0.8.20 to 0.9.6. - [Release notes](https://github.com/Microsoft/hcsshim/releases) - [Commits](https://github.com/Microsoft/hcsshim/compare/v0.8.20...v0.9.6) --- updated-dependencies: - dependency-name: github.com/Microsoft/hcsshim dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
This commit is contained in:
![49699333+dependabot[bot]@users.noreply.github.com](/assets/img/avatar_default.png)
committed by
Matthieu MOREL

parent
020b8db6ab
commit
90ed30a55a
25
vendor/github.com/Microsoft/hcsshim/internal/winapi/utils.go
generated
vendored
25
vendor/github.com/Microsoft/hcsshim/internal/winapi/utils.go
generated
vendored
@ -20,36 +20,41 @@ func Uint16BufferToSlice(buffer *uint16, bufferLength int) (result []uint16) {
|
||||
return
|
||||
}
|
||||
|
||||
// UnicodeString corresponds to UNICODE_STRING win32 struct defined here
|
||||
// https://docs.microsoft.com/en-us/windows/win32/api/ntdef/ns-ntdef-_unicode_string
|
||||
type UnicodeString struct {
|
||||
Length uint16
|
||||
MaximumLength uint16
|
||||
Buffer *uint16
|
||||
}
|
||||
|
||||
// NTSTRSAFE_UNICODE_STRING_MAX_CCH is a constant defined in ntstrsafe.h. This value
|
||||
// denotes the maximum number of wide chars a path can have.
|
||||
const NTSTRSAFE_UNICODE_STRING_MAX_CCH = 32767
|
||||
|
||||
//String converts a UnicodeString to a golang string
|
||||
func (uni UnicodeString) String() string {
|
||||
// UnicodeString is not guaranteed to be null terminated, therefore
|
||||
// use the UnicodeString's Length field
|
||||
return syscall.UTF16ToString(Uint16BufferToSlice(uni.Buffer, int(uni.Length/2)))
|
||||
return windows.UTF16ToString(Uint16BufferToSlice(uni.Buffer, int(uni.Length/2)))
|
||||
}
|
||||
|
||||
// NewUnicodeString allocates a new UnicodeString and copies `s` into
|
||||
// the buffer of the new UnicodeString.
|
||||
func NewUnicodeString(s string) (*UnicodeString, error) {
|
||||
// Get length of original `s` to use in the UnicodeString since the `buf`
|
||||
// created later will have an additional trailing null character
|
||||
length := len(s)
|
||||
if length > 32767 {
|
||||
return nil, syscall.ENAMETOOLONG
|
||||
}
|
||||
|
||||
buf, err := windows.UTF16FromString(s)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(buf) > NTSTRSAFE_UNICODE_STRING_MAX_CCH {
|
||||
return nil, syscall.ENAMETOOLONG
|
||||
}
|
||||
|
||||
uni := &UnicodeString{
|
||||
Length: uint16(length * 2),
|
||||
MaximumLength: uint16(length * 2),
|
||||
// The length is in bytes and should not include the trailing null character.
|
||||
Length: uint16((len(buf) - 1) * 2),
|
||||
MaximumLength: uint16((len(buf) - 1) * 2),
|
||||
Buffer: &buf[0],
|
||||
}
|
||||
return uni, nil
|
||||
|
Reference in New Issue
Block a user