Debian Bug report logs -
#12411
example directory lister ignores errors
Reply or subscribe to this bug.
Toggle useless messages
Report forwarded to debian-bugs-dist@lists.debian.org, Erick Branderhorst <branderh@debian.org>
:
Bug#12411
; Package glibcdoc
.
(full text, mbox, link).
Acknowledgement sent to Ian Jackson <ian@davenant.greenend.org.uk>
:
New bug report received and forwarded. Copy sent to Erick Branderhorst <branderh@debian.org>
.
(full text, mbox, link).
Message #5 received at submit@bugs.debian.org (full text, mbox, reply):
Package: glibcdoc
Version: 1.92-1
The example directory lister in (libc)Simple Directory Lister is a
very poor example, because:
* it does not check the return values from closedir or puts;
* it does not fflush stdout (so that errors writing stdout will not be
detected unless they happen more than one stdio buffer length from
the end of the output data);
* it prints the error message about failing to open the directory to
stdout instead of stderr;
* when the opendir fails it doesn't print the value of errno.
Some people might say `hey, it's only an example, it doesn't matter if
it's crap'. However, programmers using this example when writing
their own code will probably replicate many of these mistakes,
producing programs with unreliable and unhelpful error behaviours.
I suppose we can forgive it for ignoring its arguments, rather than
checking that it has none.
Ian.
Information forwarded to debian-bugs-dist@lists.debian.org, Erick Branderhorst <branderh@debian.org>
:
Bug#12411
; Package glibcdoc
.
(full text, mbox, link).
Acknowledgement sent to Vincent Renardias <vincent@waw.com>
:
Extra info received and forwarded to list. Copy sent to Erick Branderhorst <branderh@debian.org>
.
(full text, mbox, link).
Message #10 received at 12411@bugs.debian.org (full text, mbox, reply):
On Sun, 31 Aug 1997, Ian Jackson wrote:
> Package: glibcdoc
> Version: 1.92-1
This package has been superceded by libc6-doc, and should be removed from
hamm (if not already done). However the libc6 maintainer should check
if this bug is still in libc6-doc or not.
Cordialement,
--
- ** Linux ** +-------------------+ ** WAW ** -
- vincent@debian.org | RENARDIAS Vincent | vincent@waw.com -
- Debian/GNU Linux +-------------------+ http://www.waw.com/ -
- http://www.debian.org/ | WAW (33) 4 91 81 21 45 -
---------------------------------------------------------------------------
Information forwarded to debian-bugs-dist@lists.debian.org, Ian Jackson <ian@davenant.greenend.org.uk>, GNU Libc Maintainers <debian-glibc@lists.debian.org>, glibc@packages.qa.debian.org
:
Bug#12411
; Package glibc-doc
.
(full text, mbox, link).
Acknowledgement sent to "H. S. Teoh" <hsteoh@quickfur.ath.cx>
:
Extra info received and forwarded to list. Copy sent to Ian Jackson <ian@davenant.greenend.org.uk>, GNU Libc Maintainers <debian-glibc@lists.debian.org>, glibc@packages.qa.debian.org
.
(full text, mbox, link).
Message #19 received at 12411@bugs.debian.org (full text, mbox, reply):
[Message part 1 (text/plain, inline)]
tags 12411 + patch
thanks
Hi, attached is a patch that gives a better Directory Lister example.
Ian's concerns are addressed as follows:
> * it does not check the return values from closedir or puts;
Now it does.
> * it does not fflush stdout (so that errors writing stdout will not be
> detected unless they happen more than one stdio buffer length from
> the end of the output data);
I have declined to address this, since this example is mainly concerned
with using the libc directory reading functions, not with handling stdout
errors.
> * it prints the error message about failing to open the directory to
> stdout instead of stderr;
The current version of the info file uses perror(), which, as far as I
know, print to stderr, not stdout.
> * when the opendir fails it doesn't print the value of errno.
I believe using perror() gives a sufficient representation of the value of
errno.
> Some people might say `hey, it's only an example, it doesn't matter if
> it's crap'. However, programmers using this example when writing
> their own code will probably replicate many of these mistakes,
> producing programs with unreliable and unhelpful error behaviours.
I agree, except that an example starts to lose its effectiveness to convey
its intended message if real-life issues start to intrude upon it beyond
what is necessary. Using fflush on stdout is one point that IMHO is beyond
the scope of this example, although I do agree on the other points (to
emphasize that one should always check the return code of syscalls and
library calls, etc).
> I suppose we can forgive it for ignoring its arguments, rather than
> checking that it has none.
I'm tempted to also address this in my proposed fix to the example, but as
I said, this is getting near the point where it starts detracting from the
point of the example. I personally regard it as extremely bad practice to
declare main() as main(void); nevertheless, the stated purpose of this
example is that it lists files in the current directory, and as such, it
seems superfluous to declare and check for argc and argv. The official
glibc maintainers can, of course, add this additional check to the example
should they so choose.
T
--
LINUX = Lousy Interface for Nefarious Unix Xenophobes.
[12411.patch (text/plain, attachment)]
Tags added: patch
Request was from "H. S. Teoh" <hsteoh@quickfur.ath.cx>
to control@bugs.debian.org
.
(full text, mbox, link).
Information forwarded to debian-bugs-dist@lists.debian.org, GNU Libc Maintainers <debian-glibc@lists.debian.org>, glibc@packages.qa.debian.org
:
Bug#12411
; Package glibc-doc
.
(full text, mbox, link).
Acknowledgement sent to Ian Jackson <ian@davenant.greenend.org.uk>
:
Extra info received and forwarded to list. Copy sent to GNU Libc Maintainers <debian-glibc@lists.debian.org>, glibc@packages.qa.debian.org
.
(full text, mbox, link).
Message #26 received at 12411@bugs.debian.org (full text, mbox, reply):
H. S. Teoh writes ("Bug#12411: [PATCH] A better Directory Lister example"):
...
> I have declined to address this, since this example is mainly concerned
> with using the libc directory reading functions, not with handling stdout
> errors.
I actually think it's a libc bug, #28250.
> > * it prints the error message about failing to open the directory to
> > stdout instead of stderr;
>
> The current version of the info file uses perror(), which, as far as I
> know, print to stderr, not stdout.
I think some of the things I reported must have been fixed in the
meantime.
Thanks,
Ian.
Information forwarded to debian-bugs-dist@lists.debian.org, GNU Libc Maintainers <debian-glibc@lists.debian.org>, glibc@packages.qa.debian.org
:
Bug#12411
; Package glibc-doc
.
(full text, mbox, link).
Acknowledgement sent to "H. S. Teoh" <hsteoh@quickfur.ath.cx>
:
Extra info received and forwarded to list. Copy sent to GNU Libc Maintainers <debian-glibc@lists.debian.org>, glibc@packages.qa.debian.org
.
(full text, mbox, link).
Message #31 received at 12411@bugs.debian.org (full text, mbox, reply):
On Sat, Dec 28, 2002 at 12:53:28PM +0000, Ian Jackson wrote:
> H. S. Teoh writes ("Bug#12411: [PATCH] A better Directory Lister example"):
> ...
> > I have declined to address this, since this example is mainly concerned
> > with using the libc directory reading functions, not with handling stdout
> > errors.
>
> I actually think it's a libc bug, #28250.
OK, IMHO, #28250 should be considered a more encompassing bug that
includes this particular issue. I think for the purposes of #12411, it
should be sufficient to leave it as it is, since when (if) #28250 gets
resolved, we'll either have to revisit everything anyway, or it would be a
non-issue (depending on which of the two main options are taken, according
to the discussion in #28250 and related bugs).
[snip]
> > > * it prints the error message about failing to open the directory to
> > > stdout instead of stderr;
> >
> > The current version of the info file uses perror(), which, as far as I
> > know, print to stderr, not stdout.
>
> I think some of the things I reported must have been fixed in the
> meantime.
[snip]
Yep. So does the current example (+ patch) sufficiently address the issues
in this bug that it can be closed?
T
--
VI = Visual Irritation
Information forwarded to debian-bugs-dist@lists.debian.org, Ian Jackson <ian@davenant.greenend.org.uk>, GNU Libc Maintainers <debian-glibc@lists.debian.org>, glibc@packages.qa.debian.org
:
Bug#12411
; Package glibc-doc
.
(full text, mbox, link).
Acknowledgement sent to "H. S. Teoh" <hsteoh@quickfur.ath.cx>
:
Extra info received and forwarded to list. Copy sent to Ian Jackson <ian@davenant.greenend.org.uk>, GNU Libc Maintainers <debian-glibc@lists.debian.org>, glibc@packages.qa.debian.org
.
(full text, mbox, link).
Message #36 received at 12411@bugs.debian.org (full text, mbox, reply):
Hi, resending this message through X-Debbugs-CC because Ian has for
whatever reason decided to blacklist my ISP's mailserver: (Sighhh...)
> Recipient: <ian@davenant.greenend.org.uk>
> Reason: Blacklisted site `[209.226.175.35]' [Irritated]
Original message follows:
On Sat, Dec 28, 2002 at 12:53:28PM +0000, Ian Jackson wrote:
> H. S. Teoh writes ("Bug#12411: [PATCH] A better Directory Lister example"):
> ...
> > I have declined to address this, since this example is mainly concerned
> > with using the libc directory reading functions, not with handling stdout
> > errors.
>
> I actually think it's a libc bug, #28250.
OK, IMHO, #28250 should be considered a more encompassing bug that
includes this particular issue. I think for the purposes of #12411, it
should be sufficient to leave it as it is, since when (if) #28250 gets
resolved, we'll either have to revisit everything anyway, or it would be a
non-issue (depending on which of the two main options are taken, according
to the discussion in #28250 and related bugs).
[snip]
> > > * it prints the error message about failing to open the directory to
> > > stdout instead of stderr;
> >
> > The current version of the info file uses perror(), which, as far as I
> > know, print to stderr, not stdout.
>
> I think some of the things I reported must have been fixed in the
> meantime.
[snip]
Yep. So does the current example (+ patch) sufficiently address the issues
in this bug that it can be closed?
T
--
VI = Visual Irritation
Information forwarded to debian-bugs-dist@lists.debian.org, GNU Libc Maintainers <debian-glibc@lists.debian.org>
:
Bug#12411
; Package glibc-doc
.
(full text, mbox, link).
Acknowledgement sent to Lars Wirzenius <liw@iki.fi>
:
Extra info received and forwarded to list. Copy sent to GNU Libc Maintainers <debian-glibc@lists.debian.org>
.
(full text, mbox, link).
Message #41 received at 12411@bugs.debian.org (full text, mbox, reply):
[Message part 1 (text/plain, inline)]
Attached is my attempt at writing a clear, yet succinct example for
reading directory listings using opendir/readdir/closedir. I think mine
is easier to follow (a more straightforward structure), but I'd be happy
enough with the patch by H. S. Teoh.
Once sarge is released and new libc packages can be developed again, I
rather think it would be good to finally fix and close this 7 year old
bug. :)
[dirlister.c (text/x-csrc, attachment)]
Send a report that this bug log contains spam.
Debian bug tracking system administrator <owner@bugs.debian.org>.
Last modified:
Fri Apr 19 12:47:02 2024;
Machine Name:
buxtehude
Debian Bug tracking system
Debbugs is free software and licensed under the terms of the GNU
Public License version 2. The current version can be obtained
from https://bugs.debian.org/debbugs-source/.
Copyright © 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson,
2005-2017 Don Armstrong, and many other contributors.