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

G115: false positive for uintptr -> unsafe.Pointer #1202

Closed
abemedia opened this issue Sep 1, 2024 · 1 comment · Fixed by #1194
Closed

G115: false positive for uintptr -> unsafe.Pointer #1202

abemedia opened this issue Sep 1, 2024 · 1 comment · Fixed by #1194

Comments

@abemedia
Copy link

abemedia commented Sep 1, 2024

Summary

When converting a uintptr to an unsafe.Pointer I get the error G115: integer overflow conversion uintptr -> unsafe.Pointer, even though these can be safely converted (see https://pkg.go.dev/unsafe#Pointer "A uintptr can be converted to a Pointer.").

Steps to reproduce the behavior

Code sample:

package main

func main() {
	i := uintptr(123)
	p := unsafe.Pointer(i)
	_ = p
}

gosec version

v2.20.1-0.20240822074752-ab3f6c1c83a0

Go version (output of 'go version')

go version go1.23.0 darwin/amd64

Operating system / Environment

MacOS 14.6.1

Expected behavior

Passes without errors.

Actual behavior

Throws error G115: integer overflow conversion uintptr -> unsafe.Pointer

@ccojocar
Copy link
Member

ccojocar commented Sep 2, 2024

related to #1187

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants