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

Missing bounds check in array slicing #20987

Closed
arnetheduck opened this issue Dec 1, 2022 · 2 comments · Fixed by #23814
Closed

Missing bounds check in array slicing #20987

arnetheduck opened this issue Dec 1, 2022 · 2 comments · Fixed by #23814

Comments

@arnetheduck
Copy link
Contributor

Description

var v: array[1, byte]

var p = cast[ptr array[0, byte]](addr v)

echo toOpenArray(p[], 1, 2)

this should obviously cause defect but doesn't, neither at compile nor at runtime

Nim Version

1.6.8, devel

Current Output

No response

Expected Output

No response

Possible Solution

No response

Additional Information

No response

@juancarlospaco
Copy link
Collaborator

!nim c

var v: array[1, byte]
var p = cast[ptr array[0, byte]](addr v)
echo toOpenArray(p[], 1, 2)

@github-actions
Copy link
Contributor

@juancarlospaco (contributor)

devel :+1: OK

Output

[0, 0]

Stats

  • Created 2023-07-11T19:20:31Z
  • Started 2023-07-11T19:21:01
  • Finished 2023-07-11T19:21:02
  • Duration 1 minute
  • Commands nim c --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --threads:off --verbosity:0 --hints:off --warnings:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
stable :+1: OK

Output

[0, 0]

Stats

  • Created 2023-07-11T19:20:31Z
  • Started 2023-07-11T19:21:02
  • Finished 2023-07-11T19:21:03
  • Duration 1 minute
  • Commands nim c --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --threads:off --verbosity:0 --hints:off --warnings:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
1.6.0 :+1: OK

Output

[0, 0]

Stats

  • Created 2023-07-11T19:20:31Z
  • Started 2023-07-11T19:21:05
  • Finished 2023-07-11T19:21:06
  • Duration 1 minute
  • Commands nim c --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --threads:off --verbosity:0 --hints:off --warnings:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
1.4.0 :+1: OK

Output

[0, 0]

Stats

  • Created 2023-07-11T19:20:31Z
  • Started 2023-07-11T19:21:09
  • Finished 2023-07-11T19:21:09
  • Duration 1 minute
  • Commands nim c --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --threads:off --verbosity:0 --hints:off --warnings:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
1.2.0 :+1: OK

Output

[0, 0]

Stats

  • Created 2023-07-11T19:20:31Z
  • Started 2023-07-11T19:21:25
  • Finished 2023-07-11T19:21:25
  • Duration now
  • Commands nim c --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --threads:off --verbosity:0 --hints:off --warnings:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
1.0.0 :+1: OK

Output

[0, 0]

Stats

  • Created 2023-07-11T19:20:31Z
  • Started 2023-07-11T19:21:38
  • Finished 2023-07-11T19:21:38
  • Duration now
  • Commands nim c --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --threads:off --verbosity:0 --hints:off --warnings:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
0.20.2 :+1: OK

Output

[0, 0]

Stats

  • Created 2023-07-11T19:20:31Z
  • Started 2023-07-11T19:21:52
  • Finished 2023-07-11T19:21:52
  • Duration 1 minute
  • Commands nim c --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --threads:off --verbosity:0 --hints:off --warnings:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
🤖 Bug found in 54 minutes bisecting 7 commits at 0 commits per second.

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