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

Saner behavior in rb_gsl_complex_printf. #50

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jzakrzew
Copy link

Use Ruby string formatting instead of sprintf in rb_gsl_complex_printf.
This changes the behavior in some ways:

  • the function will no longer print/leak garbage from the stack if it is given a format string with too many directives. It will raise an ArgumentError instead.
  • the function can no longer crash ruby by overflowing the stack with a long format string
  • the availability and behavior of directives will match ruby sprintf and not given system's libc
  • saner type conversion rules will be used (e.g. "%d" will actually print out the integer parts of the complex number instead of reinterpreting the bits of the float as an integer)

IMHO these are desirable changes, but they do break backwards compatibility.

Jakub Zakrzewski added 2 commits September 24, 2017 00:28
Use Ruby string formatting instead of sprintf in rb_gsl_complex_printf.
This changes the behavior in some ways:
 * the function will no longer print/leak garbage from the stack if it is given a format string with too many directives. It will raise an ArgumentError instead.
 * the function can no longer crash ruby by overflowing the stack with a long format string
 * the availability and behavior of directives will match ruby sprintf and not given system's libc
 * saner type conversion rules will be used (e.g. "%d" will actually print out the integer parts of the complex number instead of reinterpreting the bits of the float as an integer)
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.

1 participant