[Chicago-talk] Slurp

Steven Lembark lembark at wrkhors.com
Tue Dec 23 16:46:26 CST 2003


> My concern is, what if some joker sends me an email with a huge
> attachment? Because I'm slurping STDIN, they could really whack me right?

You allocate virtual memory until you (a) fill the swap
segments and run out, (b) hit your process limits, or (c)
slurp the file.

Slurping things that you cannot check (e.g., STDIN) is
usually a bad idea in uncontrolled situations (e.g.,
incomming email). Downloading DNA files from GenBank is
a bit more controlled since you at least have some idea
that GB is not acting mailiciously.

A better method might be to use sysread with a fixed
buffer size that you know you can read, deal with the
contents as-is and discard anything else. That way you
can still deal with the input as a single scalar but
don't have to worry about blowing your server out of
the water.

enjoi


--
Steven Lembark                               2930 W. Palmer
Workhorse Computing                       Chicago, IL 60647
                                            +1 888 359 3508



More information about the Chicago-talk mailing list