Skip to content

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