runaway cgi process

M

Martin DeMello

Got this from the guy who hosts my shell account:
24168 zem 14 0 5800 5716 580 R 49.9 1.1 659:45 upload.cgi
10636 zem 15 0 8016 7804 576 R 47.1 1.5 722:43 upload.cgi

upload.cgi was doing a runaway CPU usage thing. Not sure why. Might
want to take a look at it and see.

Couldn't figure it either - anyone?

#!/home/zem/usr/bin/ruby

# from http://www.zytrax.com/tech/lang/ruby/#upload

require 'cgi'
require 'stringio'

puts "Content-type: text/html"
puts

cgi = CGI.new

tmpfile = cgi['datafile'].path
fromfile = cgi['datafile']

# create output file reference as original filename in our chosen directory
tofile = '/home/zem/incoming/'+fromfile.original_filename
# copy the file
# note the untaint prevents a security error
# cgi sets up an StringIO object if file < 10240
# or a Tempfile object following works for both
File.open(tofile.untaint, 'w') { |file| file << fromfile.read}

puts %{
<html>
<head>
<title>File Uploaded</title>
</head>
<body>
#{fromfile.original_filename} uploaded<br>
Size: #{fromfile.length} bytes<br>
[<a href="http://zem.novylen.net/upload.html">Upload another file</a>]
[<a href="http://zem.novylen.net">Return home</a>]
</body>
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top