bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: %q with truncating size loses safeness of %q


From: Chet Ramey
Subject: Re: %q with truncating size loses safeness of %q
Date: Sun, 19 Apr 2020 15:36:39 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko/20100101 Thunderbird/68.7.0

On 4/17/20 4:38 PM, Sam Liddicott wrote:
> So is it to be "fixed" in the documentation with a warning that
> truncating-size specifiers for %q may nullify the safety benefits for which
> it is used?

Probably something more general, along the lines of the POSIX language for
the %b directive:

"Bytes from the converted string shall be written until the end of the
string or the number of bytes indicated by the precision specification is
reached. If the precision is omitted, it shall be taken to be infinite, so
all bytes up to the end of the converted string shall be written."

The %b, %()T, and %q (and %s) directives all behave the same way: generate
the argument and print it according to the supplied fieldwidth and
precision.

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]