Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Avoid passsing possible user input directly into the shell. Instead
quote the `image_path` value before calling the `convert` command.

See here http://rubysec.com/advisories/CVE-2015-7541/ for more
information.
  • Loading branch information
flori authored and quadule committed Jan 6, 2016
1 parent d589ce0 commit 570b5e8
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/colorscore/histogram.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
require "shellwords"

module Colorscore
class Histogram
def initialize(image_path, colors=16, depth=8)
output = `convert #{image_path} -resize 400x400 -format %c -dither None -quantize YIQ -colors #{colors} -depth #{depth} histogram:info:-`
output = `convert #{image_path.shellescape} -resize 400x400 -format %c -dither None -quantize YIQ -colors #{colors.to_i} -depth #{depth.to_i} histogram:info:-`
@lines = output.lines.sort.reverse.map(&:strip).reject(&:empty?)
end

Expand Down

0 comments on commit 570b5e8

Please sign in to comment.