On 9/3/19 4:30 PM, Todd C. Miller wrote: > On Mon, 02 Sep 2019 21:15:23 +0200, Martijn van Duren wrote: > >> https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/limits.h.html >> {_POSIX_ARG_MAX} >> Maximum length of argument to the exec functions including environment da >> ta. >> Value: 4 096 > > Note that this is the minimum value POSIX requires, implementations > are allowed to have larger values. The _actual_ value on OpenBSD > is ARG_MAX which is much higher, 256 * 1024. > > Personally, I'd just use asprintf() here. The actual limit is going > to be closer to ARG_MAX - (strlen("sh) + strlen("-c") so I don't > think you are likely to get it exactly. The kernel should enforce > that limit, not smtpd. > > - todd > I choose this value because I hit the maximum command length of the shell before. This way I'm somewhat confident that the shell doesn't do something weird with my command if we ever overflow it's internal buffer. So I based it on the shell, not the kernel.
Also, I deem it extremely unlikely that any configuration ever has a filter command which reaches over _POSIX_ARG_MAX. If you feel strongly about changing it asprintf I'll prepare a diff, I just want my reasoning out there first.
