[Techtalk] system call to bin/mail from a program sometimes fails

Kai MacTane kmactane at gothpunk.com
Sat Dec 8 21:38:49 UTC 2007


Marilyn Wulfekuhler wrote:
> 
> string mailcommand;
> mailcommand = "mail -s\'Unable to get info from " + id + ". reason: "
>        + err->enumToString(err->getReason())
>        + "\' "
>        + recipients
>        + " < /dev/null";
> 
> system (mailcommand.c_str());

Is there ever any chance that reason, 
err->enumToString(err->getReason()), or recipients wind up containing 
unescaped shell metacharacters? Or does C++'s system() call 
automatically take care of those for you?

                                                 --Kai MacTane
----------------------------------------------------------------------
"Why can't I live a life for me?
  Why should I take the abuse that's served?
  Why can't they see they're just like me?
  I'm not the one that's so absurd!"
                                                 --Ministry,
                                                  "Every Day is
                                                   Halloween"


More information about the Techtalk mailing list