tags:

views:

88

answers:

1

Hello! I'm developing a little CGI application (in C, with CGIC, http://www.boutell.com/cgic/). My application needs to create a temporary file (the user upload an images, it is saved, modified in various ways, and then shown back to the user).

What precautions should I take while creating temporary files?

The modified image is provided dynamically by a CGI script which then removes the tempfile from disk:

Something like that: <html><head><title>here's your modified image</title></head><body><img src="cgi-bin/genimage.cgi?uid=5423423 /></body>

However a malicious user could upload an image and never request the modified image, so filling the hard disk.

Should I remove periodically unused files?

Many thanks!

A: 

Using CGI for direct application design is questionable -- i.e., not a web-framework/app-engine. I would suggest using Java for your image manipulation, or wrap it in lua or python or something.

If you continue with C make sure you put restrict the CGI execution environment, put it in a jail, check this post out for some inspiration, here is another one.

Hassan Syed