mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Fix unsigned to signed integer conversion in syserr.getHostTranslation().
unix.Errno is of type `uintptr`, which is an unsigned integer. It was being casted to `int`, which is a signed integer of the same size. This cast could overflow due to unsigned -> signed. Reported-by: syzbot+08e5bf6f25d7db4316b9@syzkaller.appspotmail.com PiperOrigin-RevId: 680668525
This commit is contained in:
@@ -28,7 +28,7 @@ const maxErrno = 107
|
||||
var darwinHostTranslations [maxErrno]*Error
|
||||
|
||||
func getHostTranslation(err unix.Errno) *Error {
|
||||
if int(err) >= len(darwinHostTranslations) {
|
||||
if uint64(err) >= uint64(len(darwinHostTranslations)) {
|
||||
return nil
|
||||
}
|
||||
return darwinHostTranslations[err]
|
||||
|
||||
@@ -29,7 +29,7 @@ const maxErrno = 134
|
||||
var linuxHostTranslations [maxErrno]*Error
|
||||
|
||||
func getHostTranslation(err unix.Errno) *Error {
|
||||
if int(err) >= len(linuxHostTranslations) {
|
||||
if uint64(err) >= uint64(len(linuxHostTranslations)) {
|
||||
return nil
|
||||
}
|
||||
return linuxHostTranslations[err]
|
||||
|
||||
Reference in New Issue
Block a user