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

Possible out of bounds string access in std/colors parseColor and isColor #14839

Closed
liquidev opened this issue Jun 28, 2020 · 0 comments
Closed

Comments

@liquidev
Copy link
Contributor

liquidev commented Jun 28, 2020

As in the title.

Example

import std/colors

echo "".isColor

https://play.nim-lang.org/#ix=2qp5

Current Output

/usercode/in.nim(3)      in
/playground/nim/lib/pure/colors.nim(475) isColor
/playground/nim/lib/system/fatal.nim(49) sysFatal
Error: unhandled exception: index out of bounds, the container is empty [IndexError]

Expected Output

false

Possible Solution

This should be very simple to fix.
https://github.com/nim-lang/Nim/blob/devel/lib/pure/colors.nim#L455
Simply add name.len > 0 to the if statement condition in parseColor and isColor.

Additional Information

❯ nim -v
Nim Compiler Version 1.2.0 [Linux: amd64]
Compiled at 2020-04-03
Copyright (c) 2006-2020 by Andreas Rumpf

active boot switches: -d:release

Checking the source code, this issue is still present on devel.

liquidev added a commit to liquidev/Nim that referenced this issue Jun 28, 2020
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

No branches or pull requests

1 participant