Re: How to check for perl or usable printf tools?

Simon Josefsson via Bug reports for the GNU Internet utilities <[email protected]>
Newsgroups gmane.comp.gnu.inetutils.bugs
Message-ID <[email protected]>
Erik Auerswald <[email protected]> writes:

> I am trying to use the reported input file that crashes tftp for the test.
> This file contains non-printable characters (i.e., it is a "binary" file).
> I do not want to add this binary file as-is to the git repository.

Why?  I don't see anything fundamentally wrong with commiting a binary
fuzz file that trigger som particular bad behaviour.

> Thus I want to create the contents with some widely available tool from
> some description, e.g., hexadecimal byte values.

Awk or ed?

Or 'od'?

> One possibility is printf.  It seems to me as if printf(1) is not yet used
> in GNU Inetutils.  Both the Bash builtin version and the GNU Coreutils
> version of printf support "\xHH" in the format string.  But the Debian
> Almquist Shell (dash) builtin printf does not, at least not in dash
> version 0.5.8-2.10.  The "\xHH" escape sequence is not specified by POSIX.
> (Perhaps I could use octal instead of hexadecimal, since that is specified
> by POSIX, and the printf built into dash supports it.)  Thus we would
> need to check for a usable printf implementation first.  But Autoconf
> does not seem to contain such a macro (I did not see "AC_PROG_PRINTF"
> in the documentation).

If printf is already a fragile tool for this, it sounds like it will
cause problems.

> Another possibility is perl.  Perl is already used in GNU Inetutils,
> for the "bootstrap" script and for "whois".  I did not see an obvious
> perl check in Autoconf (i.e., no "AC_PROG_PERL") in the documentation.
> The test script would need to test if perl is available to avoid a false
> positive test result with broken tftp.

It is only required for developers and 'make dist', isn't it?

> I think I'll just hack something together with printf and octal escape
> sequences, but I would prefer a "proper" Autoconf-based approach.
> Help with Autoconf would be appreciated.

I can help with it, but sounds like it would be nice to settle on a
solution we believe is portable first.

Maybe 'perl' is actually the simplest, and the self-test should SKIP
when perl isn't available?

/Simon
signature.asc (application/pgp-signature, 255 B)
-----BEGIN PGP SIGNATURE-----

iIoEARYIADIWIQSjzJyHC50xCrrUzy9RcisI/kdFogUCYx72OxQcc2ltb25Aam9z
ZWZzc29uLm9yZwAKCRBRcisI/kdFomZ3AP98zc6bmfSppATLQyk8B3ceS0OO2GAC
4sK8y2mOneIGEwEApL2x0yr2K909WIwSmI/LSOaDsMAPA/kFgKnMtCt6Ewo=
=X+/f
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.