Paul Eggert wrote: > I have not pushed this, as I understand you're trying to put out a > release, but this fixes some portability bugs in 'stat', such that it > was relying on undefined behavior, which presumably could cause > 'stat' to dump core, or worse, on non-GNU platforms. > > The downside of this patch is that the "I" printf flag is now ignored. > However, support for "I" wasn't working anyway (because of time stamp > fractions), so this isn't much of a loss. We can add proper "I" > support later, if there's demand for it. > > Subject: [PATCH] stat: do not rely on undefined behavior in printf formats > > * src/stat.c (digits, printf_flags): New static vars. > (make_format): New function. > (out_string, out_int, out_uint, out_uint_o, out_uint_x): > (out_minus_zero): Use it to avoid undefined behavior when invoking > printf. > (print_it): Check for invalid conversion specifications such as > %..X and %1-X, which would otherwise rely on undefined behavior > when invoking printf. > * tests/misc/stat-nanoseconds: Check that the "I" printf flag > doesn't mess up in the C locale, as it formerly did on non-GNU > hosts.
Thanks for the patch! I looked through it, applied it and tested it. I see fixes (admittedly fringe, as you say, but still) and don't see anything that might cause trouble, so go ahead and push it. Nobody will miss the "I" flag. I think I've never even seen it used.
