bug-groff
[Top][All Lists]
Advanced

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

Re: [bug #55449] [PATCH] Use FILENAME_MAX in maxfilename.cpp


From: Ingo Schwarze
Subject: Re: [bug #55449] [PATCH] Use FILENAME_MAX in maxfilename.cpp
Date: Thu, 22 Oct 2020 01:11:59 +0200
User-agent: Mutt/1.12.2 (2019-09-21)

Hi Carsten,

Carsten Kunze hat am 21. Oktober 2020 um 21:23 geschrieben:

> How about at first using pathconf(3) with the constant _PC_NAME_MAX
> to determine the file name length (for a specfific path) and using
> the constants only when pathconf returns -1?

The file already does that, if pathconf(3) is available.
The code right before my patch reads:

  #ifdef _POSIX_VERSION
  size_t file_name_max(const char *fname)
  {
    return pathconf(fname, _PC_NAME_MAX);
  }
  #else /* not _POSIX_VERSION */

Now, arguably, if pathconf(3) fails, which can easily happen if the
input argument is garbage, the function should not return (size_t)-1,
which is a large value.

In particular since typical places where the the return value is
checked regard (size_t)-1 as a valid positive size:

src/libs/libgroff/tmpfile.cpp:
  if (file_name_max(tem2) <= 14) {
    /* be unhappy */

src/utils/indxbib/indxbib.cpp:
  name_max = file_name_max(dir);
  if (strlen(filename) + sizeof(INDEX_SUFFIX) - 1 > name_max)
    fatal(...)

But that is beside the point of this ticket.

I'm not opening a ticket for this new bug because i don't doubt
that the code is full of errors of similar kinds and that finding
lots of them is trivial, so opening a ticket for this particular
one would just be noise.  Starting a code audit and producing
*patches* (as opposed to producing *tickets* that merely clog the
bugtracker) would no doubt be useful, but it would be a lot of work.

Anyone willing to fix this particular bug?
  Ingo


Carsten Kunze wrote on Wed, Oct 21, 2020 at 11:07:54PM +0200:

> I forgot it need to compile on Windows--sorry for the noise.

Asking questions about patches is not noise.  Even if it turns out
the idea contained in a question cannot be used as-is, questions
often trigger further investigation that results in further
improvements.

In this case, i pushed the patch as-is though, given that gbranden@
and eliz@ agreed and that the file already uses pathconf(3).

Yours,
  Ingo



reply via email to

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