Skip to content

Fix integer overflow - #84

Merged
alexherrero merged 3 commits into
google:masterfrom
apurv15:master
Jun 12, 2025
Merged

alexherrero merged 3 commits into
google:masterfrom
apurv15:master

Conversation

@apurv15

@apurv15 apurv15 commented May 31, 2025

Copy link
Copy Markdown
Contributor

Use %v as formatter instead of %d to prevent overflow on Windows ARM which treats int as 32 bit value.

@google-cla

google-cla Bot commented May 31, 2025

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@apurv15

apurv15 commented Jun 7, 2025

Copy link
Copy Markdown
Contributor Author

@brandonweeks, @bourey, @sethvargo : Can one of you look at this small code change and approve?

@sethvargo

Copy link
Copy Markdown

Hey hey,

  1. Both of those variables are 32-bit (uint32), so I'm not sure why overflow would happen?

  2. I'd have to double check, but I'm pretty sure %v reflects on the value and calls the more specific underlying function relative to the type, which would be the same function that %d calls:

    CleanShot 2025-06-07 at 09 45 47@2x

  3. I don't have permissions to approve these changes on this repo.

@apurv15

apurv15 commented Jun 10, 2025

Copy link
Copy Markdown
Contributor Author

Thanks @sethvargo for the comments. This is the error reported with Windows build:

env:
CGO_ENABLED: 0
GOOS: windows
GOARCH: arm
GOARM: 7
build
##[error]vendor/github.com/google/certtostore/certtostore_windows.go:1087:60: cannot use ncryptKeySpec (untyped int constant 4294967295) as int value in argument to fmt.Errorf (overflows)

keyspec returned by cryptAcquireCertificatePrivateKey is unsigned int while ncryptKeySpec is defined as untyped constant and when printed with %d will result in overflow. I have explicitly defined ncryptKeySpec as uint32 now.

@apurv15 apurv15 changed the title Use %v as formatter instead of %d to prevent overflow Fix integer overflow Jun 10, 2025
@sethvargo

Copy link
Copy Markdown

Can you share the full stack trace please?

@apurv15

apurv15 commented Jun 11, 2025

Copy link
Copy Markdown
Contributor Author

@sethvargo

Copy link
Copy Markdown

Okay this seems like a more reasonable fix. I still don't have permissions to approve it though :)

@apurv15

apurv15 commented Jun 12, 2025

Copy link
Copy Markdown
Contributor Author

Thanks.
@mit-da, @brandonweeks, @bourey : Can one of you approve this small change?

@alexherrero
alexherrero merged commit 1412463 into google:master Jun 12, 2025
copybara-service Bot pushed a commit that referenced this pull request Jun 13, 2025
PiperOrigin-RevId: 771250112
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 this pull request may close these issues.

4 participants