Hi Pádraig,

> The attached should fix up those tests.

I disagree with the removal of the '%' checks in tests/test-sh-quote.c
and tests/test-system-quote-main.c. These checks are there to guarantee
that the functions won't write past the allocated buffer. For example,
sh-quote.h specifies how large the buffer must be:

/* Copies the quoted string to p and returns the incremented p.
   There must be room for shell_quote_length (string) + 1 bytes at p.  */
extern char * shell_quote_copy (char *p, const char *string);

system-quote.h specifies it similarly:

/* Copies the quoted string to p and returns the incremented p.
   There must be room for system_quote_length (string) + 1 bytes at p.  */
extern char *
       system_quote_copy (char *p,
                          enum system_command_interpreter interpreter,
                          const char *string);

The tests verify this. Please can you restore the checks and instead
see why quotearg now writes more bytes than necessary?

Note that both shell_quote_length and shell_quote_copy are defined
through the 'quotearg' module, with the same options (called
'sh_quoting_options' there). The buffer overrun indicates an internal
inconsistency in the 'quotearg' module.

Bruno


Reply via email to