Project

General

Profile

Actions

Defect #15801

closed

500 Internal Server Error in some roadmap views

Added by Stefano Gargiulo about 10 years ago. Updated about 10 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
Ruby support
Target version:
-
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Invalid
Affected version:

Description

After upgrading redmine to latest version and upgrading ruby to 1.9.3 I was getting this error in some projects roadmap views:

Completed 500 Internal Server Error in 43.5ms

ActionView::Template::Error (undefined method `size' for 9.307692307692308:Float):
    16: <% end %>
    17: 
    18: <% if version.issues_count > 0 %>
    19:     <%= progress_bar([version.closed_percent, version.completed_percent],
    20:                      :width => '40em', :legend => ('%0.0f%' % version.completed_percent)) %>
    21:     <p class="progress-info">
    22:       <%= link_to(l(:label_x_issues, :count => version.issues_count), 
  config/initializers/bigdecimal-segfault-fix.rb:25:in `BigDecimal'
  app/models/version.rb:262:in `estimated_average'
  app/models/version.rb:284:in `issues_progress'
  app/models/version.rb:133:in `closed_percent'
  app/views/versions/_overview.html.erb:19:in `_app_views_versions__overview_html_erb__1380710332190949155_70281938910760'
  app/views/versions/index.html.erb:14:in `block in _app_views_versions_index_html_erb___2154825363913482942_70281943739680'
  app/views/versions/index.html.erb:12:in `each'
  app/views/versions/index.html.erb:12:in `_app_views_versions_index_html_erb___2154825363913482942_70281943739680'

undefined method `size' for 9.307692307692308:Float

i rawly fixed it adding a "try catch" to bigdecimal_segfault.rb (i'm not a ruby developer so there's surely a better method to check if the object has the size method, anyway i post my fix here for reference because it seems to make it working:

cat config/initializers/bigdecimal-segfault-fix.rb
# Copyright (c) 2009 Michael Koziarski <michael@koziarski.com>
# 
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
# 
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

require 'bigdecimal'

alias BigDecimalUnsafe BigDecimal

# This fixes CVE-2009-1904 however it removes legitimate functionality that your
# application may depend on.  You are *strongly* advised to upgrade your ruby
# rather than relying on this fix for an extended period of time.

def BigDecimal(initial, digits=0)
  begin
    if initial.size > 255 || initial =~ /e/i
      raise "Invalid big Decimal Value" 
    end
  rescue Exception => e
  #do noth
  end
  BigDecimalUnsafe(initial, digits)
end

Actions #1

Updated by Toshi MARUYAMA about 10 years ago

  • Status changed from New to Closed
  • Resolution set to Invalid

bigdecimal-segfault-fix.rb was removed by r8788.

Actions

Also available in: Atom PDF