autofs-5.1.9 - fix buffer overflow in prepend_opt()

A stack buffer overflow and missing NULL terminator in prepend_opt()
which affects autofs versions from 5.1.0 has been identified.

When building mount options an oversized AMD map `OPTION` token can
overflow the fixed 1024-byte stack buffer used to build mount options
and the copied-back string also loses its terminating NULL during AMD
map parsing.

Fix it by making prepend_opt() bounded, copy back the terminating
`\0`, and fail parsing when the combined option string would exceed
`MAX_OPTS_LEN`.

This patch was provided as part of a vulnerability report which was
generated using AI technology.

Reported-By: AISLE Research
Fixes: 6f065977a6 ("autofs-5.0.9 - amd lookup add parse_amd.c")
Signed-off-by: Ian Kent <raven@themaw.net>
2 files changed